05-09-2013, 09:48 PM | #1 |
Grand Sorcerer
Posts: 6,171
Karma: 16228536
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
Access to calibre functions via ActivePython IDLE?
I hope this is not a dumb question... I'm using ActiveState ActivePython IDLE on Win 7 as my interactive Python environment. I'm not trying to create my own run-from-source version of calibre but I am trying to understand some of calibre's existing classes and functions. I was hoping to set things up so that simple import commands e.g.
Code:
from calibre.ptempfile import PersistentTemporaryDirectory from calibre.constants import iswindows from calibre import guess_type I had hoped that downloading a calibre archive and taking a copy of dir calibre\src\calibre to my own test area might do the trick but I must be missing some important initial action (some kind of setup ??? perhaps) because I always get an error something like Code:
sys.path.insert(0, sys.extensions_location) AttributeError: 'module' object has no attribute 'extensions_location' Is what I want to do possible? |
05-09-2013, 10:48 PM | #2 |
creator of calibre
Posts: 43,776
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Just run calibre-debug with no arguments to get an interactive python prompt where you can import stuff from calibre.
|
05-09-2013, 11:20 PM | #3 |
Grand Sorcerer
Posts: 6,171
Karma: 16228536
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
But doesn't that give me an interactive session in an non-friendly Windows CMD box?
Can I run calibre-debug from the IDLE shell instead? |
05-10-2013, 02:02 AM | #4 |
creator of calibre
Posts: 43,776
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
No, not really. What is so friendly about the IDLE prompt (I dont use IDLE)? If you dont like CMD, you can get better console utilities for windows. IIRC there is Console2 or something like that.
|
05-10-2013, 04:02 AM | #5 |
Grand Sorcerer
Posts: 11,703
Karma: 6658935
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
@jackie_w: my guess is that you want to use an IDE-based debugger so you can set breakpoints, inspect objects, and the like. I have never found a way to do something like this, but I confess I haven't looked very hard. My guess is that the only way you might succeed is to run stuff using calibre-debug from inside the IDE. Exactly how you accomplish that is a mystery.
I just use test code snippets and print statements. If needed I stick the print statements in the middle of calibre code so I can see intermediate results. I have even from time to time changed the base startup code so that it runs what I want when starting the gui (stuff in gui2/ui.py). Given that there is no compilation or link time penalty, this actually works out to be quite practical. |
05-10-2013, 08:29 AM | #6 |
Grand Sorcerer
Posts: 6,171
Karma: 16228536
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
Thanks for the feedback, guys.
It's not so much what's great about IDLE as what's not great about the CMD box, e.g. Fixed width window, no colour coding, plus I can copy/paste code from my text editor into the CMD box, but not vice versa. I make a lot of errors (I suspect you make rather less ) it takes me a while to get things working. Nevertheless you've given me an idea. My text editor, Notepad++, has a Console plugin. This might be the answer. My current area of interest is the Container class used in Polish, plus the versions in Modify Epub and the KoboTouchExtended driver. I'm not sure which I should consider the 'master' version. A couple of years ago I created something for myself which could read/store data from a single selected epub (either in the calibre database or just a .epub on disk) so that I could do 'updating stuff'. It never occurred to me that I'd cobbled together a 'container' of sorts, different data structures of course. Modify Epub now does some of those update things (rather better than I was doing them), but I still have a daily requirement for other personal epub updating. I thought maybe it was time to try using an official calibre epub container. |
05-10-2013, 08:34 AM | #7 |
creator of calibre
Posts: 43,776
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You should use the Polish container class (which will allow you to modify both epub and azw3). If you are sure you want to only stick to epub, you canu use the container from modify epub if you prefer the way it works (the two work differently).
|
05-10-2013, 08:51 AM | #8 |
Grand Sorcerer
Posts: 6,171
Karma: 16228536
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
Can you outline the main differences?
I want to use one which someone else will be maintaining so I guess that doesn't rule out either of them. I currently convert azw3 to epub before doing anything else. That won't change unless Amazon manage to kill off decent epub readers. I will definitely need to be able to access/update the actual html data contained in the html files and css data in the css file(s). Does that point me at one container rather than the other? |
05-10-2013, 11:05 AM | #9 |
creator of calibre
Posts: 43,776
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I dont know much about the container in modify epub, so I cant really help.
|
05-10-2013, 11:28 AM | #10 | |
Grand Sorcerer
Posts: 6,171
Karma: 16228536
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
OK I'll start with the Polish version and see how far I can get. I was a little disturbed when I saw this comment in the Modify Epub version:
Quote:
|
|
05-10-2013, 11:35 AM | #11 |
creator of calibre
Posts: 43,776
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
That comment refers to an outdated container class that was used by the (now discontinued) epub-fix utility in calibre.
|
05-10-2013, 11:54 AM | #12 |
Grand Sorcerer
Posts: 6,171
Karma: 16228536
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
Ah, that's good. It sounds like the Polish one is what I need to try get to grips with. Could be a long weekend.
|
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Short Fiction Jerome, Jerome K.: Idle Thoughts of an Idle Fellow (Illustrated), v2. 25 May 2012 | GrannyGrump | ePub Books | 5 | 10-18-2014 11:54 AM |
Certain Functions of Calibre Not Working? | BasilGrows | Calibre | 1 | 06-08-2012 12:14 AM |
Most often used calibre functions | thearr | Calibre | 17 | 08-07-2011 02:44 PM |
Help Understanding Calibre Functions | Knocka | Calibre | 8 | 04-08-2009 11:31 PM |
Jerome, Jerome K.: Idle Thoughts of an Idle Fellow. v1, 31 Dec 2007 | Madam Broshkina | BBeB/LRF Books | 0 | 12-31-2007 08:54 PM |