![]() |
#1 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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 ![]() |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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
![]() |
![]() |
![]() |
![]() |
|
![]() |
||||
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 |