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

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

Notices

Reply
 
Thread Tools Search this Thread
Old 11-21-2009, 05:38 PM   #1
macr0t0r
Connoisseur
macr0t0r doesn't littermacr0t0r doesn't litter
 
macr0t0r's Avatar
 
Posts: 91
Karma: 108
Join Date: Jan 2008
Device: Palm Treo 680, Sony Reader
Question Importing local files within a plugin

So, I'm working on a plugin to automate generating HTML from a PDB that is specially-suited for the Sony PRS-500 LRF format(don't ask, my Mom refuses to send hers in for an upgrade for fear of losing it). I already have the scripts that do this, but they are broken into separate files and reference each other with the "import" command.

However, once I zip them up into a plugin, the import fails. The main function is called, but it can't find the other files. Originally, I just did:
"import filename"
since they were in the same folder. How should I reference these files so they can be found within the plugin? I'd hate to have to try and mash them all together into a single file.

- Jim
macr0t0r is offline   Reply With Quote
Old 11-21-2009, 07:41 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: 43,776
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
the plugin system will give your plugin a path to the zip file in self.plugin_path. You can just add that to sys.path like this

Code:
sys.path.insert(0, self.plugin_path)
Then your imports should work.
kovidgoyal is offline   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
Error importing mobi files Nomadin Calibre 27 02-19-2010 04:15 AM
Importing HTML Files Shadowlane Calibre 1 12-19-2009 03:04 PM
Importing files onto a Kindle Dahak Amazon Kindle 7 05-19-2009 12:12 AM
Error when importing MobiPocket files. mbovenka Calibre 7 08-16-2008 10:07 AM
Kindle Browser and local files slm Amazon Kindle 2 06-03-2008 08:29 PM


All times are GMT -4. The time now is 10:21 PM.


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