Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 05-09-2013, 10:48 PM   #1
jackie_w
Wizard
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: 2,913
Karma: 4329601
Join Date: Sep 2009
Location: UK
Device: Sony PRS-350, PB360, Kobo Glo/AuraHD/Aura6"/AuraH2O
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
could be entered from IDLE without giving errors.

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'
I'm aware that I can use the calibre-debug -e option to run my own .py script but I'm finding it very laborious when all I'm trying to do is find out what type of thing (dict, list, method, string etc) a particular calibre item is and to examine some variables. I find it much easier to understand code if I can see the contents of the variables involved.

Is what I want to do possible?
jackie_w is online now   Reply With Quote
Old 05-09-2013, 11:48 PM   #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: 26,438
Karma: 5383257
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.
kovidgoyal is offline   Reply With Quote
 
Advertisement
Old 05-10-2013, 12:20 AM   #3
jackie_w
Wizard
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: 2,913
Karma: 4329601
Join Date: Sep 2009
Location: UK
Device: Sony PRS-350, PB360, Kobo Glo/AuraHD/Aura6"/AuraH2O
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?
jackie_w is online now   Reply With Quote
Old 05-10-2013, 03:02 AM   #4
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: 26,438
Karma: 5383257
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.
kovidgoyal is offline   Reply With Quote
Old 05-10-2013, 05:02 AM   #5
chaley
"chaley", not "charley"
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 5,909
Karma: 1217216
Join Date: Jan 2010
Location: France
Device: Many android devices
@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.
chaley is offline   Reply With Quote
Old 05-10-2013, 09:29 AM   #6
jackie_w
Wizard
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: 2,913
Karma: 4329601
Join Date: Sep 2009
Location: UK
Device: Sony PRS-350, PB360, Kobo Glo/AuraHD/Aura6"/AuraH2O
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.
jackie_w is online now   Reply With Quote
Old 05-10-2013, 09:34 AM   #7
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: 26,438
Karma: 5383257
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).
kovidgoyal is offline   Reply With Quote
Old 05-10-2013, 09:51 AM   #8
jackie_w
Wizard
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: 2,913
Karma: 4329601
Join Date: Sep 2009
Location: UK
Device: Sony PRS-350, PB360, Kobo Glo/AuraHD/Aura6"/AuraH2O
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?
jackie_w is online now   Reply With Quote
Old 05-10-2013, 12:05 PM   #9
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: 26,438
Karma: 5383257
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I dont know much about the container in modify epub, so I cant really help.
kovidgoyal is offline   Reply With Quote
Old 05-10-2013, 12:28 PM   #10
jackie_w
Wizard
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: 2,913
Karma: 4329601
Join Date: Sep 2009
Location: UK
Device: Sony PRS-350, PB360, Kobo Glo/AuraHD/Aura6"/AuraH2O
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:
Originally this plugin tried to use a Container class used in the calibre source code. However having overriden so many methods to fix bugs or alter behaviour to suit my needs in the end I gave up on inheritance and copied.
... but I don't suppose the current Polish version was around when Modify Epub was first written. Perhaps if kiwidude ever drops by this thread he'll shed some light.
jackie_w is online now   Reply With Quote
Old 05-10-2013, 12:35 PM   #11
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: 26,438
Karma: 5383257
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.
kovidgoyal is offline   Reply With Quote
Old 05-10-2013, 12:54 PM   #12
jackie_w
Wizard
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: 2,913
Karma: 4329601
Join Date: Sep 2009
Location: UK
Device: Sony PRS-350, PB360, Kobo Glo/AuraHD/Aura6"/AuraH2O
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.
jackie_w is online now   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

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 12:54 PM
Certain Functions of Calibre Not Working? BasilGrows Calibre 1 06-08-2012 01:14 AM
Most often used calibre functions thearr Calibre 17 08-07-2011 03:44 PM
Help Understanding Calibre Functions Knocka Calibre 8 04-09-2009 12:31 AM
Jerome, Jerome K.: Idle Thoughts of an Idle Fellow. v1, 31 Dec 2007 Madam Broshkina BBeB/LRF Books 0 12-31-2007 09:54 PM


All times are GMT -4. The time now is 01:55 PM.


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