View Single Post
Old 01-08-2009, 10:52 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,449
Karma: 5383257
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
on_import = True causes the plugin to run just before the file is added to the database, but not before metadata is read from the file. If you want to change metadata reading, create a metadatareader plugin.

Getting the path to the calibre install directory is platform and installation method dependent. Here is some code to find the path to the plugins subdirectory ina calibre install

Code:
            if iswindows:
                plugin_path = os.path.join(os.path.dirname(sys.executable), 'plugins')
                sys.path.insert(1, os.path.dirname(sys.executable))
            elif isosx:
                plugin_path = os.path.join(getattr(sys, 'frameworks_dir'), 'plugins')
            elif islinux:
                plugin_path = os.path.join(getattr(sys, 'frozen_path'), 'plugins')
Note that you shouldn't need to know the path to the calibre install directory in your plugins.
kovidgoyal is offline   Reply With Quote