View Full Version : Convert Book ID to Library filename


Agama
08-10-2012, 06:52 PM
Is there a function that I can call that takes a Book ID as input and returns the generic filename of the book, (i.e. no extension), without the full library path?

kovidgoyal
08-10-2012, 11:01 PM
construct_path_name() and construct_file_name()

Agama
08-14-2012, 08:21 PM
construct_file_name() returned exactly what I expected but construct_path_name() returned a folder path relative to the library. Is there anyway to return the full OS path to the library folder?

For example: C:\Folders\Books\Main\Dickens, Charles\The Pickwick Papers (168)

kovidgoyal
08-14-2012, 11:49 PM
db.library_path

Agama
08-15-2012, 08:44 AM
Thanks, that completes the set!

All 3 of these work without me adding any extra import statements to the plugin.
How do I know when an import is required or not? Do I just try first without and see if it fails?

For example, in the same plugin I have "from calibre.ebooks.metadata.meta import get_metadata" and this one is necessary for use of get_metadata.

kovidgoyal
08-15-2012, 09:49 AM
import statements add names to the current namespace. If the name is already present, like db then you dont need to import it.