def get_fff_config(url,fileform="epub",personalini=None): if not personalini: personalini = get_fff_personalini() sections=['unknown'] try: sections = adapters.getConfigSectionsFor(url) except Exception as e: logger.debug("Failed trying to get ini config for url(%s): %s, using section %s instead"%(url,e,sections)) configuration = Configuration(sections,fileform) configuration.readfp(StringIO(ensure_text(get_resources("plugin-defaults.ini")))) configuration.readfp(StringIO(ensure_text(personalini))) return configuration
def cli_main(self, argv): with self: # so the sys.path was modified appropriately # I believe there's no performance hit loading these here when # CLI--it would load everytime anyway. from calibre.library import db from fanficfare.cli import main as fff_main from calibre_plugins.fanficfare_plugin.prefs import PrefsFacade from fanficfare.six import ensure_text from optparse import OptionParser parser = OptionParser('%prog --run-plugin ' + self.name + ' -- [options] <storyurl>') parser.add_option( '--library-path', '--with-library', default=None, help= _('Path to the calibre library. Default is to use the path stored in the settings.' )) # parser.add_option('--dont-notify-gui', default=False, action='store_true', # help=_('Do not notify the running calibre GUI (if any) that the database has' # ' changed. Use with care, as it can lead to database corruption!')) pargs = [ x for x in argv if x.startswith('--with-library') or x.startswith('--library-path') or not x.startswith('-') ] opts, args = parser.parse_args(pargs) fff_prefs = PrefsFacade(db(path=opts.library_path, read_only=True)) fff_main( argv[1:], parser=parser, passed_defaultsini=ensure_text( get_resources("fanficfare/defaults.ini")), passed_personalini=ensure_text(fff_prefs["personal.ini"]), )