mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
more cleanups
This commit is contained in:
parent
8f97e09d0b
commit
44f6c0a1f5
@ -2,7 +2,7 @@ from __future__ import with_statement
|
|||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
import atexit, os, shutil, sys, tempfile, zipfile
|
import os, sys, zipfile
|
||||||
|
|
||||||
from calibre.constants import numeric_version
|
from calibre.constants import numeric_version
|
||||||
from calibre.ptempfile import PersistentTemporaryFile
|
from calibre.ptempfile import PersistentTemporaryFile
|
||||||
@ -226,7 +226,7 @@ class MetadataWriterPlugin(Plugin):
|
|||||||
|
|
||||||
'''
|
'''
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class CatalogPlugin(Plugin):
|
class CatalogPlugin(Plugin):
|
||||||
'''
|
'''
|
||||||
A plugin that implements a catalog generator.
|
A plugin that implements a catalog generator.
|
||||||
@ -251,7 +251,7 @@ class CatalogPlugin(Plugin):
|
|||||||
#: '%default' + "'"))]
|
#: '%default' + "'"))]
|
||||||
|
|
||||||
cli_options = []
|
cli_options = []
|
||||||
|
|
||||||
|
|
||||||
def search_sort_db(self, db, opts):
|
def search_sort_db(self, db, opts):
|
||||||
|
|
||||||
@ -262,7 +262,7 @@ class CatalogPlugin(Plugin):
|
|||||||
if opts.sort_by:
|
if opts.sort_by:
|
||||||
# 2nd arg = ascending
|
# 2nd arg = ascending
|
||||||
db.sort(opts.sort_by, True)
|
db.sort(opts.sort_by, True)
|
||||||
|
|
||||||
return db.get_data_as_dict(ids=opts.ids)
|
return db.get_data_as_dict(ids=opts.ids)
|
||||||
|
|
||||||
def get_output_fields(self, opts):
|
def get_output_fields(self, opts):
|
||||||
@ -289,29 +289,29 @@ class CatalogPlugin(Plugin):
|
|||||||
'''
|
'''
|
||||||
If plugin is not a built-in, copy the plugin's .ui and .py files from
|
If plugin is not a built-in, copy the plugin's .ui and .py files from
|
||||||
the zip file to $TMPDIR.
|
the zip file to $TMPDIR.
|
||||||
Tab will be dynamically generated and added to the Catalog Options dialog in
|
Tab will be dynamically generated and added to the Catalog Options dialog in
|
||||||
calibre.gui2.dialogs.catalog.py:Catalog
|
calibre.gui2.dialogs.catalog.py:Catalog
|
||||||
'''
|
'''
|
||||||
from calibre.customize.builtins import plugins as builtin_plugins
|
from calibre.customize.builtins import plugins as builtin_plugins
|
||||||
from calibre.customize.ui import config
|
from calibre.customize.ui import config
|
||||||
from calibre.ptempfile import PersistentTemporaryDirectory
|
from calibre.ptempfile import PersistentTemporaryDirectory
|
||||||
|
|
||||||
if not type(self) in builtin_plugins and \
|
if not type(self) in builtin_plugins and \
|
||||||
not self.name in config['disabled_plugins']:
|
not self.name in config['disabled_plugins']:
|
||||||
files_to_copy = ["%s.%s" % (self.name.lower(),ext) for ext in ["ui","py"]]
|
files_to_copy = ["%s.%s" % (self.name.lower(),ext) for ext in ["ui","py"]]
|
||||||
resources = zipfile.ZipFile(self.plugin_path,'r')
|
resources = zipfile.ZipFile(self.plugin_path,'r')
|
||||||
|
|
||||||
if self.resources_path is None:
|
if self.resources_path is None:
|
||||||
self.resources_path = PersistentTemporaryDirectory('_plugin_resources', prefix='')
|
self.resources_path = PersistentTemporaryDirectory('_plugin_resources', prefix='')
|
||||||
|
|
||||||
for file in files_to_copy:
|
for file in files_to_copy:
|
||||||
try:
|
try:
|
||||||
resources.extract(file, self.resources_path)
|
resources.extract(file, self.resources_path)
|
||||||
except:
|
except:
|
||||||
print " customize:__init__.initialize(): %s not found in %s" % (file, os.path.basename(self.plugin_path))
|
print " customize:__init__.initialize(): %s not found in %s" % (file, os.path.basename(self.plugin_path))
|
||||||
continue
|
continue
|
||||||
resources.close()
|
resources.close()
|
||||||
|
|
||||||
def run(self, path_to_output, opts, db, ids):
|
def run(self, path_to_output, opts, db, ids):
|
||||||
'''
|
'''
|
||||||
Run the plugin. Must be implemented in subclasses.
|
Run the plugin. Must be implemented in subclasses.
|
||||||
|
@ -9,20 +9,20 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
from calibre.gui2 import gprefs
|
from calibre.gui2 import gprefs
|
||||||
from calibre.gui2.catalog.catalog_csv_xml_ui import Ui_Form
|
from calibre.gui2.catalog.catalog_csv_xml_ui import Ui_Form
|
||||||
from PyQt4.Qt import QDialog, QWidget, SIGNAL
|
from PyQt4.Qt import QWidget
|
||||||
|
|
||||||
class PluginWidget(QWidget,Ui_Form):
|
class PluginWidget(QWidget,Ui_Form):
|
||||||
|
|
||||||
TITLE = _('CSV/XML Output')
|
TITLE = _('CSV/XML Output')
|
||||||
HELP = _('Options specific to')+' CSV/XML '+_('output')
|
HELP = _('Options specific to')+' CSV/XML '+_('output')
|
||||||
sync_enabled = False
|
sync_enabled = False
|
||||||
|
|
||||||
def initialize(self, name):
|
def initialize(self, name):
|
||||||
QWidget.__init__(self)
|
QWidget.__init__(self)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.name = name
|
self.name = name
|
||||||
# Restore the activated fields from last use
|
# Restore the activated fields from last use
|
||||||
for x in range(self.db_fields.count()):
|
for x in range(self.db_fields.count()):
|
||||||
pref = '%s_db_fields_%s' % (self.name, self.db_fields.item(x).text())
|
pref = '%s_db_fields_%s' % (self.name, self.db_fields.item(x).text())
|
||||||
activated = gprefs[pref] if pref in gprefs else False
|
activated = gprefs[pref] if pref in gprefs else False
|
||||||
self.db_fields.item(x).setSelected(activated)
|
self.db_fields.item(x).setSelected(activated)
|
||||||
@ -31,10 +31,10 @@ class PluginWidget(QWidget,Ui_Form):
|
|||||||
# Save the currently activated fields
|
# Save the currently activated fields
|
||||||
for x in range(self.db_fields.count()):
|
for x in range(self.db_fields.count()):
|
||||||
pref = '%s_db_fields_%s' % (self.name, self.db_fields.item(x).text())
|
pref = '%s_db_fields_%s' % (self.name, self.db_fields.item(x).text())
|
||||||
gprefs[pref] = self.db_fields.item(x).isSelected()
|
gprefs[pref] = self.db_fields.item(x).isSelected()
|
||||||
|
|
||||||
# Return a dictionary with current options for this widget
|
# Return a dictionary with current options for this widget
|
||||||
if len(self.db_fields.selectedItems()):
|
if len(self.db_fields.selectedItems()):
|
||||||
return {'fields':[str(item.text()) for item in self.db_fields.selectedItems()]}
|
return {'fields':[str(item.text()) for item in self.db_fields.selectedItems()]}
|
||||||
else:
|
else:
|
||||||
return {'fields':['all']}
|
return {'fields':['all']}
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
from __future__ import with_statement
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
|
||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
|
||||||
__docformat__ = 'restructuredtext en'
|
|
||||||
|
|
||||||
|
|
||||||
from <basename> import Ui_Form
|
|
||||||
from PyQt4.Qt import QDialog, QWidget
|
|
||||||
|
|
||||||
class PluginWidget(QWidget,Ui_Form):
|
|
||||||
|
|
||||||
TITLE = _('<formats> Output')
|
|
||||||
HELP = _('Options specific to')+' <formats> '+_('output')
|
|
||||||
# Indicates whether this plugin wants its output synced to the connected device
|
|
||||||
sync_enabled = False
|
|
||||||
|
|
||||||
def initialize(self):
|
|
||||||
QWidget.__init__(self)
|
|
||||||
self.setupUi(self)
|
|
||||||
|
|
||||||
def options(self):
|
|
||||||
# Return a dictionary with options for this Widget
|
|
||||||
return {}
|
|
Loading…
x
Reference in New Issue
Block a user