mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
unnecessary collection call and some dict with keyword arguments (extra-edit)
This commit is contained in:
parent
bd59bf631e
commit
5d7c9a4cf3
@ -21,6 +21,6 @@ class ParisReview(BasicNewsRecipe):
|
||||
# remove_attributes = ['style',]
|
||||
# keep_only_tags = []
|
||||
remove_tags = []
|
||||
# remove_tags_before = dict()
|
||||
# remove_tags_before = {}
|
||||
remove_tags_after = {}
|
||||
feeds = [('Posts', 'http://feeds.feedburner.com/TheParisReviewBlog')]
|
||||
|
@ -91,10 +91,10 @@ class Bookmark: # {{{
|
||||
|
||||
if entry_type:
|
||||
displayed_location = location // MAGIC_MOBI_CONSTANT + 1
|
||||
user_notes[location] = dict(id=self.id,
|
||||
displayed_location=displayed_location,
|
||||
type=entry_type,
|
||||
text=text)
|
||||
user_notes[location] = {'id': self.id,
|
||||
'displayed_location': displayed_location,
|
||||
'type': entry_type,
|
||||
'text': text}
|
||||
|
||||
eo += rec_len + 8
|
||||
current_entry += 1
|
||||
@ -127,10 +127,10 @@ class Bookmark: # {{{
|
||||
if end_loc != self.last_read:
|
||||
# print(' adding Bookmark at 0x%x (%d)' % (end_loc, end_loc/MAGIC_MOBI_CONSTANT + 1))
|
||||
displayed_location = end_loc // MAGIC_MOBI_CONSTANT + 1
|
||||
user_notes[end_loc - 1] = dict(id=self.id,
|
||||
displayed_location=displayed_location,
|
||||
type='Bookmark',
|
||||
text=None)
|
||||
user_notes[end_loc - 1] = {'id': self.id,
|
||||
'displayed_location': displayed_location,
|
||||
'type': 'Bookmark',
|
||||
'text': None}
|
||||
rec_len, = unpack('>I', data[eo+4:eo+8])
|
||||
eo += rec_len + 8
|
||||
sig = data[eo:eo+4]
|
||||
@ -200,10 +200,10 @@ class Bookmark: # {{{
|
||||
e_type = 'Unknown annotation type'
|
||||
|
||||
displayed_location = location/MAGIC_TOPAZ_CONSTANT + 1
|
||||
user_notes[location] = dict(id=self.id,
|
||||
displayed_location=displayed_location,
|
||||
type=e_type,
|
||||
text=text)
|
||||
user_notes[location] = {'id': self.id,
|
||||
'displayed_location': displayed_location,
|
||||
'type': e_type,
|
||||
'text': text}
|
||||
if text_len == 0xFFFFFFFF:
|
||||
e_base = e_base + 14
|
||||
else:
|
||||
@ -263,10 +263,10 @@ class Bookmark: # {{{
|
||||
displayed_location = location
|
||||
e_type = 'Bookmark'
|
||||
text = None
|
||||
user_notes[location] = dict(id=self.id,
|
||||
displayed_location=displayed_location,
|
||||
type=e_type,
|
||||
text=text)
|
||||
user_notes[location] = {'id': self.id,
|
||||
'displayed_location': displayed_location,
|
||||
'type': e_type,
|
||||
'text': text}
|
||||
self.pdf_page_offset = pdf_location - location
|
||||
e_base += (7 + label_len)
|
||||
current_entry += 1
|
||||
|
@ -245,7 +245,7 @@ class KINDLE(USBMS):
|
||||
if mc_path:
|
||||
timestamp = utcfromtimestamp(os.path.getmtime(mc_path))
|
||||
bookmarked_books['clippings'] = self.UserAnnotation(type='kindle_clippings',
|
||||
value=dict(path=mc_path, timestamp=timestamp))
|
||||
value={'path': mc_path, 'timestamp': timestamp})
|
||||
|
||||
# This returns as job.result in gui2.ui.annotations_fetched(self,job)
|
||||
return bookmarked_books
|
||||
|
@ -126,14 +126,14 @@ class Bookmark: # {{{
|
||||
|
||||
# book_title = row[8]
|
||||
chapter_progress = min(round(float(100*row['ChapterProgress']),2),100)
|
||||
user_notes[note_id] = dict(id=self.id,
|
||||
displayed_location=note_id,
|
||||
type=e_type,
|
||||
text=text,
|
||||
annotation=annotation,
|
||||
chapter=current_chapter,
|
||||
chapter_title=chapter_title,
|
||||
chapter_progress=chapter_progress)
|
||||
user_notes[note_id] = {'id': self.id,
|
||||
'displayed_location': note_id,
|
||||
'type': e_type,
|
||||
'text': text,
|
||||
'annotation': annotation,
|
||||
'chapter': current_chapter,
|
||||
'chapter_title': chapter_title,
|
||||
'chapter_progress': chapter_progress}
|
||||
previous_chapter = current_chapter
|
||||
# debug_print("e_type:" , e_type, '\t', 'loc: ', note_id, 'text: ', text,
|
||||
# 'annotation: ', annotation, 'chapter_title: ', chapter_title,
|
||||
|
@ -267,8 +267,7 @@ TAG_INFO = dict(
|
||||
setemptyview=(0xF52A, {'show':1, 'empty':0}, writeWord),
|
||||
pageposition=(0xF52B, {'any':0,'upper':1, 'lower':2}, writeWord),
|
||||
evensidemargin=(0xF52C, writeWord),
|
||||
framemode=(0xF52E,
|
||||
{'None':0, 'curve':2, 'square':1}, writeWord),
|
||||
framemode=(0xF52E, {'None':0, 'curve':2, 'square':1}, writeWord),
|
||||
blockwidth=(0xF531, writeWord),
|
||||
blockheight=(0xF532, writeWord),
|
||||
blockrule=(0xF533, {'horz-fixed':0x14, 'horz-adjustable':0x12,
|
||||
|
@ -238,8 +238,8 @@ class MetadataUpdater:
|
||||
offset += consumed
|
||||
len_comp, consumed = self.decode_vwi(self.data[offset:offset+4])
|
||||
offset += consumed
|
||||
blocks[val] = dict(offset=hdr_offset,len_uncomp=len_uncomp,len_comp=len_comp)
|
||||
topaz_headers[tag] = dict(blocks=blocks)
|
||||
blocks[val] = {'offset': hdr_offset,'len_uncomp': len_uncomp,'len_comp': len_comp}
|
||||
topaz_headers[tag] = {'blocks': blocks}
|
||||
th_seq.append(tag)
|
||||
self.eoth = self.data[offset]
|
||||
offset += 1
|
||||
|
@ -332,23 +332,24 @@ def render_jacket(mi, output_profile,
|
||||
|
||||
def generate_html(comments):
|
||||
display = Attributes()
|
||||
args = dict(xmlns=XHTML_NS,
|
||||
title_str=title_str,
|
||||
identifiers=Identifiers(mi.identifiers),
|
||||
css=css,
|
||||
title=title,
|
||||
author=author,
|
||||
publisher=publisher, publisher_label=_('Publisher'),
|
||||
pubdate_label=_('Published'), pubdate=Timestamp(pubdate, tweaks['gui_pubdate_display_format']),
|
||||
series_label=ngettext('Series', 'Series', 1), series=series,
|
||||
rating_label=_('Rating'), rating=rating,
|
||||
tags_label=_('Tags'), tags=tags,
|
||||
timestamp=Timestamp(timestamp, tweaks['gui_timestamp_display_format']), timestamp_label=_('Date'),
|
||||
comments=comments,
|
||||
footer='',
|
||||
display=display,
|
||||
searchable_tags=' '.join(escape(t)+'ttt' for t in tags.tags_list),
|
||||
)
|
||||
args = {
|
||||
'xmlns': XHTML_NS,
|
||||
'title_str': title_str,
|
||||
'identifiers': Identifiers(mi.identifiers),
|
||||
'css': css,
|
||||
'title': title,
|
||||
'author': author,
|
||||
'publisher': publisher, 'publisher_label': _('Publisher'),
|
||||
'pubdate_label': _('Published'), 'pubdate': Timestamp(pubdate, tweaks['gui_pubdate_display_format']),
|
||||
'series_label': ngettext('Series', 'Series', 1), 'series': series,
|
||||
'rating_label': _('Rating'), 'rating': rating,
|
||||
'tags_label': _('Tags'), 'tags': tags,
|
||||
'timestamp': Timestamp(timestamp, tweaks['gui_timestamp_display_format']), 'timestamp_label': _('Date'),
|
||||
'comments': comments,
|
||||
'footer': '',
|
||||
'display': display,
|
||||
'searchable_tags': ' '.join(escape(t)+'ttt' for t in tags.tags_list),
|
||||
}
|
||||
for key in mi.custom_field_keys():
|
||||
m = mi.get_user_metadata(key, False) or {}
|
||||
try:
|
||||
|
@ -102,7 +102,7 @@ class FetchAnnotationsAction(InterfaceAction):
|
||||
path = get_device_path_from_id(id)
|
||||
mi = db.get_metadata(id, index_is_id=True)
|
||||
a_path = device.create_annotations_path(mi, device_path=path)
|
||||
path_map[id] = dict(path=a_path, fmts=get_formats(id))
|
||||
path_map[id] = {'path': a_path, 'fmts': get_formats(id)}
|
||||
return path_map
|
||||
|
||||
device = self.gui.device_manager.device
|
||||
|
@ -1168,7 +1168,7 @@ class CatalogBuilder:
|
||||
authors=book['authors'])
|
||||
myMeta.author_sort = book['author_sort']
|
||||
a_path = d.create_upload_path('/<storage>', myMeta, 'x.bookmark', create_dirs=False)
|
||||
path_map[id] = dict(path=a_path, fmts=[x.rpartition('.')[2] for x in book['formats']])
|
||||
path_map[id] = {'path': a_path, 'fmts': [x.rpartition('.')[2] for x in book['formats']]}
|
||||
|
||||
path_map, book_ext = _resolve_bookmark_paths(self.opts.connected_device['storage'], path_map)
|
||||
if path_map:
|
||||
|
@ -29,26 +29,26 @@ plugboard_save_to_disk_value = 'save_to_disk'
|
||||
DEFAULT_TEMPLATE = '{author_sort}/{title}/{title} - {authors}'
|
||||
DEFAULT_SEND_TEMPLATE = '{author_sort}/{title} - {authors}'
|
||||
|
||||
FORMAT_ARG_DESCS = dict(
|
||||
title=_('The title'),
|
||||
authors=_('The authors'),
|
||||
author_sort=_('The author sort string. To use only the first letter '
|
||||
FORMAT_ARG_DESCS = {
|
||||
'title': _('The title'),
|
||||
'authors': _('The authors'),
|
||||
'author_sort': _('The author sort string. To use only the first letter '
|
||||
'of the name use {author_sort[0]}'),
|
||||
tags=_('The tags'),
|
||||
series=_('The series'),
|
||||
series_index=_('The series number. '
|
||||
'tags': _('The tags'),
|
||||
'series': _('The series'),
|
||||
'series_index': _('The series number. '
|
||||
'To get leading zeros use {series_index:0>3s} or '
|
||||
'{series_index:>3s} for leading spaces'),
|
||||
rating=_('The rating'),
|
||||
isbn=_('The ISBN'),
|
||||
publisher=_('The publisher'),
|
||||
timestamp=_('The date'),
|
||||
pubdate=_('The published date'),
|
||||
last_modified=_('The date when the metadata for this book record'
|
||||
'rating': _('The rating'),
|
||||
'isbn': _('The ISBN'),
|
||||
'publisher': _('The publisher'),
|
||||
'timestamp': _('The date'),
|
||||
'pubdate': _('The published date'),
|
||||
'last_modified': _('The date when the metadata for this book record'
|
||||
' was last modified'),
|
||||
languages=_('The language(s) of this book'),
|
||||
id=_('The calibre internal id')
|
||||
)
|
||||
'languages': _('The language(s) of this book'),
|
||||
'id': _('The calibre internal id')
|
||||
}
|
||||
|
||||
FORMAT_ARGS = {}
|
||||
for x in FORMAT_ARG_DESCS:
|
||||
|
@ -72,11 +72,11 @@ def get_wordcount(text):
|
||||
non_asian_words = nonj_len(text)
|
||||
words = non_asian_words + asian_chars
|
||||
|
||||
return dict(characters=characters,
|
||||
chars_no_spaces=chars_no_spaces,
|
||||
asian_chars=asian_chars,
|
||||
non_asian_words=non_asian_words,
|
||||
words=words)
|
||||
return {'characters': characters,
|
||||
'chars_no_spaces': chars_no_spaces,
|
||||
'asian_chars': asian_chars,
|
||||
'non_asian_words': non_asian_words,
|
||||
'words': words}
|
||||
|
||||
|
||||
def dict2obj(dictionary):
|
||||
|
@ -38,8 +38,7 @@ from polyglot.builtins import string_or_bytes
|
||||
|
||||
def classes(classes):
|
||||
q = frozenset(classes.split(' '))
|
||||
return dict(attrs={
|
||||
'class': lambda x: x and frozenset(x.split()).intersection(q)})
|
||||
return dict(attrs={'class': lambda x: x and frozenset(x.split()).intersection(q)})
|
||||
|
||||
|
||||
def prefixed_classes(classes):
|
||||
|
Loading…
x
Reference in New Issue
Block a user