View Single Post
Old 10-23-2010, 09:15 AM   #1
KevinH
Guru
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 749
Karma: 285540
Join Date: Nov 2009
Device: many
Plugin Developer Question

Hi Kovid,

I have one piece of code that for support purposes, plays 3 roles. First it can be run standalone as a command line tool, second it can be imported into other python code (for code reuse) and last it can be a plugin for calibre.

I can use __name__ = '__main__' for detecting it as a standalone, but I need to a way to determine if imported from some other python code versus imported by the calibre python code.

So is there some string in __name__ that will definitely tell me I am being imported as a plugin from calibre code that won't change with where calibre is installed or from version to version of calibre (because keeping up with your release schedule would kill any normal human being).

Thanks,

KevinH
KevinH is offline   Reply With Quote