Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 06-10-2015, 07:37 AM   #1
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,251
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
Using Polish remove_unused_css method

I'm interested in automatically running the remove_unused_css method from calibre.ebooks.oeb.polish.css as part of one of my personal plugins which is a gui CSS tweaker.

The input parameters are (container, report=None, remove_unused_classes=False).
I'm OK with 1 and 3 but I'm not sure how to use report.

As far as I can tell, the method just returns True/False depending on whether any css rules or html classes were removed. I'd like to be able to access some detail of what changed, which I can see is being 'reported'.

I'm afraid the documented help param report: An optional callable that takes a single argument. It is called with information about the operations being performed. doesn't enlighten me.

The fact that I don't really understand calibre's logging system may be at the heart of my problems so if there's a 'Start-here-and-all-will-be-revealed' feel free to point me at it. Understanding the logging system is probably long overdue on my part.

Thanks in advance for any helpful info
jackie_w is offline   Reply With Quote
Old 06-10-2015, 09:15 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,334
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Just use print as the report function to print to stdout. Or use

log = []

remove_unused_css(..., report=log.append)

then log will be a list of strings.
kovidgoyal is online now   Reply With Quote
Advert
Old 06-10-2015, 09:33 AM   #3
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,251
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
I should have known it would be simpler than I realised. I can manage with either of those. Thanks
jackie_w is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
When to polish books? Ma'am-I-Am Library Management 5 08-31-2014 01:50 AM
Polish error jgaiser Calibre 7 08-27-2014 01:14 PM
repository with Polish recipes t3d Recipes 15 05-22-2012 04:32 AM
New polish sources fenuks Recipes 0 10-02-2011 09:18 AM
Polish fonts kanonka Sony Reader Dev Corner 33 01-15-2011 08:28 PM


All times are GMT -4. The time now is 01:30 AM.


MobileRead.com is a privately owned, operated and funded community.