Fixes for 89e2638cdd

This commit is contained in:
Kovid Goyal 2019-05-27 12:44:29 +05:30
parent a2c4d44688
commit fe5aac9d97
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
5 changed files with 24 additions and 24 deletions

View File

@ -211,7 +211,7 @@ class Plugin(object): # {{{
For example to load an image:: For example to load an image::
pixmap = QPixmap() pixmap = QPixmap()
pixmap.loadFromData(tuple(self.load_resources(['images/icon.png']).values())[0]) pixmap.loadFromData(self.load_resources(['images/icon.png'])['images/icon.png'])
icon = QIcon(pixmap) icon = QIcon(pixmap)
:param names: List of paths to resources in the ZIP file using / as separator :param names: List of paths to resources in the ZIP file using / as separator
@ -247,7 +247,7 @@ class Plugin(object): # {{{
:param gui: If True return HTML help, otherwise return plain text help. :param gui: If True return HTML help, otherwise return plain text help.
''' '''
raise NotImplementedError raise NotImplementedError()
def temporary_file(self, suffix): def temporary_file(self, suffix):
''' '''

View File

@ -42,7 +42,7 @@ class ConversionOption(object):
return hash(self.name) return hash(self.name)
def __eq__(self, other): def __eq__(self, other):
return hash(self) == hash(other) return self.name == other.name
def clone(self): def clone(self):
return ConversionOption(name=self.name, help=self.help, return ConversionOption(name=self.name, help=self.help,
@ -143,7 +143,7 @@ class InputFormatPlugin(Plugin):
#: Set of file types for which this plugin should be run #: Set of file types for which this plugin should be run
#: For example: ``set(['azw', 'mobi', 'prc'])`` #: For example: ``set(['azw', 'mobi', 'prc'])``
file_types = set([]) file_types = set()
#: If True, this input plugin generates a collection of images, #: If True, this input plugin generates a collection of images,
#: one per HTML file. This can be set dynamically, in the convert method #: one per HTML file. This can be set dynamically, in the convert method
@ -180,11 +180,11 @@ class InputFormatPlugin(Plugin):
#: Options to customize the behavior of this plugin. Every option must be an #: Options to customize the behavior of this plugin. Every option must be an
#: instance of :class:`OptionRecommendation`. #: instance of :class:`OptionRecommendation`.
options = set([]) options = set()
#: A set of 3-tuples of the form #: A set of 3-tuples of the form
#: (option_name, recommended_value, recommendation_level) #: (option_name, recommended_value, recommendation_level)
recommendations = set([]) recommendations = set()
def __init__(self, *args): def __init__(self, *args):
Plugin.__init__(self, *args) Plugin.__init__(self, *args)
@ -226,7 +226,7 @@ class InputFormatPlugin(Plugin):
subsequent stages of the conversion. subsequent stages of the conversion.
''' '''
raise NotImplementedError raise NotImplementedError()
def __call__(self, stream, options, file_ext, log, def __call__(self, stream, options, file_ext, log,
accelerators, output_dir): accelerators, output_dir):
@ -337,7 +337,7 @@ class OutputFormatPlugin(Plugin):
:param log: The logger. Print debug/info messages etc. using this. :param log: The logger. Print debug/info messages etc. using this.
''' '''
raise NotImplementedError raise NotImplementedError()
@property @property
def is_periodical(self): def is_periodical(self):

View File

@ -267,8 +267,8 @@ class OutputProfile(Plugin):
periodical_date_in_title = True periodical_date_in_title = True
#: Characters used in jackets and catalogs #: Characters used in jackets and catalogs
ratings_char = u'*' ratings_char = '*'
empty_ratings_char = u' ' empty_ratings_char = ' '
#: Unsupported unicode characters to be replaced during preprocessing #: Unsupported unicode characters to be replaced during preprocessing
unsupported_unicode_chars = [] unsupported_unicode_chars = []
@ -302,12 +302,12 @@ class iPadOutput(OutputProfile):
} }
] ]
ratings_char = u'\u2605' # filled star ratings_char = '\u2605' # filled star
empty_ratings_char = u'\u2606' # hollow star empty_ratings_char = '\u2606' # hollow star
touchscreen = True touchscreen = True
# touchscreen_news_css {{{ # touchscreen_news_css {{{
touchscreen_news_css = u''' touchscreen_news_css = '''
/* hr used in articles */ /* hr used in articles */
.article_articles_list { .article_articles_list {
width:18%; width:18%;
@ -680,8 +680,8 @@ class KindleOutput(OutputProfile):
supports_mobi_indexing = True supports_mobi_indexing = True
periodical_date_in_title = False periodical_date_in_title = False
empty_ratings_char = u'\u2606' empty_ratings_char = '\u2606'
ratings_char = u'\u2605' ratings_char = '\u2605'
mobi_ems_per_blockquote = 2.0 mobi_ems_per_blockquote = 2.0
@ -699,8 +699,8 @@ class KindleDXOutput(OutputProfile):
# comic_screen_size = (741, 1022) # comic_screen_size = (741, 1022)
supports_mobi_indexing = True supports_mobi_indexing = True
periodical_date_in_title = False periodical_date_in_title = False
empty_ratings_char = u'\u2606' empty_ratings_char = '\u2606'
ratings_char = u'\u2605' ratings_char = '\u2605'
mobi_ems_per_blockquote = 2.0 mobi_ems_per_blockquote = 2.0

View File

@ -361,7 +361,7 @@ def metadata_readers():
def metadata_writers(): def metadata_writers():
ans = set([]) ans = set()
for plugins in _metadata_writers.values(): for plugins in _metadata_writers.values():
for plugin in plugins: for plugin in plugins:
ans.add(plugin) ans.add(plugin)
@ -557,7 +557,7 @@ def plugin_for_output_format(fmt):
def available_output_formats(): def available_output_formats():
formats = set([]) formats = set()
for plugin in output_format_plugins(): for plugin in output_format_plugins():
if not is_disabled(plugin): if not is_disabled(plugin):
formats.add(plugin.file_type) formats.add(plugin.file_type)
@ -751,16 +751,16 @@ def build_plugin(path):
from calibre.utils.zipfile import ZipFile, ZIP_STORED from calibre.utils.zipfile import ZipFile, ZIP_STORED
path = unicode_type(path) path = unicode_type(path)
names = frozenset(os.listdir(path)) names = frozenset(os.listdir(path))
if u'__init__.py' not in names: if '__init__.py' not in names:
prints(path, ' is not a valid plugin') prints(path, ' is not a valid plugin')
raise SystemExit(1) raise SystemExit(1)
t = PersistentTemporaryFile(u'.zip') t = PersistentTemporaryFile(u'.zip')
with ZipFile(t, u'w', ZIP_STORED) as zf: with ZipFile(t, 'w', ZIP_STORED) as zf:
zf.add_dir(path, simple_filter=lambda x:x in {'.git', '.bzr', '.svn', '.hg'}) zf.add_dir(path, simple_filter=lambda x:x in {'.git', '.bzr', '.svn', '.hg'})
t.close() t.close()
plugin = add_plugin(t.name) plugin = add_plugin(t.name)
os.remove(t.name) os.remove(t.name)
prints(u'Plugin updated:', plugin.name, plugin.version) prints('Plugin updated:', plugin.name, plugin.version)
def option_parser(): def option_parser():

View File

@ -162,7 +162,7 @@ class XMLCache(object):
def purge_broken_playlist_items(self, root): def purge_broken_playlist_items(self, root):
id_map = self.build_id_map(root) id_map = self.build_id_map(root)
for pl in root.xpath('//*[local-name()="playlist"]'): for pl in root.xpath('//*[local-name()="playlist"]'):
seen = set([]) seen = set()
for item in list(pl): for item in list(pl):
id_ = item.get('id', None) id_ = item.get('id', None)
if id_ is None or id_ in seen or id_map.get(id_, None) is None: if id_ is None or id_ in seen or id_map.get(id_, None) is None:
@ -573,7 +573,7 @@ class XMLCache(object):
id_ = self.max_id(root)+1 id_ = self.max_id(root)+1
attrib = { attrib = {
'page':'0', 'part':'0','pageOffset':'0','scale':'0', 'page':'0', 'part':'0','pageOffset':'0','scale':'0',
'id':unicod_type(id_), 'sourceid':'1', 'path':lpath} 'id':unicode_type(id_), 'sourceid':'1', 'path':lpath}
ans = root.makeelement('{%s}text'%namespace, attrib=attrib, nsmap=root.nsmap) ans = root.makeelement('{%s}text'%namespace, attrib=attrib, nsmap=root.nsmap)
root.append(ans) root.append(ans)
return ans return ans