diff --git a/.bzrignore b/.bzrignore index a071a4f2f6..aa6637bc7a 100644 --- a/.bzrignore +++ b/.bzrignore @@ -30,3 +30,4 @@ nbproject/ .project .pydevproject .settings/ +*.DS_Store diff --git a/recipes/fronda.recipe b/recipes/fronda.recipe index f57c7ecccb..452dca9068 100644 --- a/recipes/fronda.recipe +++ b/recipes/fronda.recipe @@ -21,14 +21,19 @@ class Fronda(BasicNewsRecipe): feeds = [(u'Infformacje', u'http://fronda.pl/news/feed')] - keep_only_tags = [dict(name='h1', attrs={'class':'big'}), - dict(name='ul', attrs={'class':'about clear'}), - dict(name='div', attrs={'class':'content'})] + keep_only_tags = [dict(name='h2', attrs={'class':'news_title'}), + dict(name='div', attrs={'class':'naglowek_tresc'}), + dict(name='div', attrs={'id':'czytaj'}) ] + + remove_tags = [dict(name='a', attrs={'class':'print'})] + preprocess_regexps = [ (re.compile(i[0], re.IGNORECASE | re.DOTALL), i[1]) for i in - [ (r'Drukuj', lambda match: ''), - (r'
', lambda match: ''), + [ (r'', lambda match: ''), (r'', lambda match: ''), (r']*>
', lambda match: ''), + (r'' + _( + 'Manage authors. Use to rename authors and correct ' + 'individual author\'s sort values') + '
') + self.manage_authors_button.clicked.connect(self.authors.manage_authors) + self.series = SeriesEdit(self) self.remove_unused_series_button = QToolButton(self) self.remove_unused_series_button.setToolTip( @@ -161,6 +173,12 @@ class MetadataSingleDialogBase(ResizableDialog): self.clear_identifiers_button = QToolButton(self) self.clear_identifiers_button.setIcon(QIcon(I('trash.png'))) self.clear_identifiers_button.clicked.connect(self.identifiers.clear) + self.paste_isbn_button = QToolButton(self) + self.paste_isbn_button.setToolTip('' + + _('Paste the contents of the clipboard into the ' + 'identifiers box prefixed with isbn:') + '
') + self.paste_isbn_button.setIcon(QIcon(I('edit-paste.png'))) + self.paste_isbn_button.clicked.connect(self.identifiers.paste_isbn) self.publisher = PublisherEdit(self) self.basic_metadata_widgets.append(self.publisher) @@ -176,7 +194,12 @@ class MetadataSingleDialogBase(ResizableDialog): font.setBold(True) self.fetch_metadata_button.setFont(font) - self.config_metadata_button = QToolButton(self) + if self.use_toolbutton_for_config_metadata: + self.config_metadata_button = QToolButton(self) + self.config_metadata_button.setIcon(QIcon(I('config.png'))) + else: + self.config_metadata_button = QPushButton(self) + self.config_metadata_button.setText(_('Configure download metadata')) self.config_metadata_button.setIcon(QIcon(I('config.png'))) self.config_metadata_button.clicked.connect(self.configure_metadata) self.config_metadata_button.setToolTip( @@ -499,7 +522,8 @@ class MetadataSingleDialog(MetadataSingleDialogBase): # {{{ sto(one, two) sto(two, three) - tl.addWidget(self.swap_title_author_button, 0, 0, 2, 1) + tl.addWidget(self.swap_title_author_button, 0, 0, 1, 1) + tl.addWidget(self.manage_authors_button, 1, 0, 1, 1) create_row(0, self.title, self.deduce_title_sort_button, self.title_sort) sto(self.title_sort, self.authors) @@ -508,6 +532,7 @@ class MetadataSingleDialog(MetadataSingleDialogBase): # {{{ create_row(2, self.series, self.remove_unused_series_button, self.series_index, icon='trash.png') sto(self.series_index, self.swap_title_author_button) + sto(self.swap_title_author_button, self.manage_authors_button) tl.addWidget(self.formats_manager, 0, 6, 3, 1) @@ -518,7 +543,7 @@ class MetadataSingleDialog(MetadataSingleDialogBase): # {{{ self.tabs[0].gb = gb = QGroupBox(_('Change cover'), self) gb.l = l = QGridLayout() gb.setLayout(l) - sto(self.swap_title_author_button, self.cover.buttons[0]) + sto(self.manage_authors_button, self.cover.buttons[0]) for i, b in enumerate(self.cover.buttons[:3]): l.addWidget(b, 0, i, 1, 1) sto(b, self.cover.buttons[i+1]) @@ -532,10 +557,16 @@ class MetadataSingleDialog(MetadataSingleDialogBase): # {{{ w.setLayout(w.l) l.setMargin(0) self.splitter.addWidget(w) - def create_row2(row, widget, button=None): + def create_row2(row, widget, button=None, front_button=None): row += 1 ql = BuddyLabel(widget) - l.addWidget(ql, row, 0, 1, 1) + if front_button: + ltl = QHBoxLayout() + ltl.addWidget(front_button) + ltl.addWidget(ql) + l.addLayout(ltl, row, 0, 1, 1) + else: + l.addWidget(ql, row, 0, 1, 1) l.addWidget(widget, row, 1, 1, 2 if button is None else 1) if button is not None: l.addWidget(button, row, 2, 1, 1) @@ -550,8 +581,10 @@ class MetadataSingleDialog(MetadataSingleDialogBase): # {{{ create_row2(1, self.rating) sto(self.rating, self.tags) create_row2(2, self.tags, self.tags_editor_button) - sto(self.tags_editor_button, self.identifiers) - create_row2(3, self.identifiers, self.clear_identifiers_button) + sto(self.tags_editor_button, self.paste_isbn_button) + sto(self.paste_isbn_button, self.identifiers) + create_row2(3, self.identifiers, self.clear_identifiers_button, + front_button=self.paste_isbn_button) sto(self.clear_identifiers_button, self.timestamp) create_row2(4, self.timestamp, self.timestamp.clear_button) sto(self.timestamp.clear_button, self.pubdate) @@ -589,6 +622,7 @@ class MetadataSingleDialogAlt1(MetadataSingleDialogBase): # {{{ cc_two_column = False one_line_comments_toolbar = True + use_toolbutton_for_config_metadata = False on_drag_enter = pyqtSignal() @@ -624,13 +658,11 @@ class MetadataSingleDialogAlt1(MetadataSingleDialogBase): # {{{ self.tabs[0].l.addWidget(gb, 0, 0, 1, 1) gb.setLayout(tl) - self.button_box.addButton(self.fetch_metadata_button, - QDialogButtonBox.ActionRole) - self.config_metadata_button.setToolButtonStyle(Qt.ToolButtonTextOnly) - self.config_metadata_button.setText(_('Configure metadata downloading')) - self.button_box.addButton(self.config_metadata_button, - QDialogButtonBox.ActionRole) - sto(self.button_box, self.title) + self.button_box_layout.insertWidget(1, self.fetch_metadata_button) + self.button_box_layout.insertWidget(2, self.config_metadata_button) + sto(self.button_box, self.fetch_metadata_button) + sto(self.fetch_metadata_button, self.config_metadata_button) + sto(self.config_metadata_button, self.title) def create_row(row, widget, tab_to, button=None, icon=None, span=1): ql = BuddyLabel(widget) @@ -648,6 +680,8 @@ class MetadataSingleDialogAlt1(MetadataSingleDialogBase): # {{{ sto(widget, tab_to) tl.addWidget(self.swap_title_author_button, 0, 0, 2, 1) + tl.addWidget(self.manage_authors_button, 2, 0, 1, 1) + tl.addWidget(self.paste_isbn_button, 11, 0, 1, 1) create_row(0, self.title, self.title_sort, button=self.deduce_title_sort_button, span=2, @@ -669,6 +703,9 @@ class MetadataSingleDialogAlt1(MetadataSingleDialogBase): # {{{ button=self.timestamp.clear_button, icon='trash.png') create_row(11, self.identifiers, self.comments, button=self.clear_identifiers_button, icon='trash.png') + sto(self.clear_identifiers_button, self.swap_title_author_button) + sto(self.swap_title_author_button, self.manage_authors_button) + sto(self.manage_authors_button, self.paste_isbn_button) tl.addItem(QSpacerItem(1, 1, QSizePolicy.Fixed, QSizePolicy.Expanding), 12, 1, 1 ,1) @@ -708,7 +745,6 @@ class MetadataSingleDialogAlt1(MetadataSingleDialogBase): # {{{ gb = QGroupBox(_('Change cover'), tab1) l = QGridLayout() gb.setLayout(l) - sto(self.swap_title_author_button, self.cover.buttons[0]) for i, b in enumerate(self.cover.buttons[:3]): l.addWidget(b, 0, i, 1, 1) sto(b, self.cover.buttons[i+1]) @@ -738,6 +774,7 @@ class MetadataSingleDialogAlt2(MetadataSingleDialogBase): # {{{ cc_two_column = False one_line_comments_toolbar = True + use_toolbutton_for_config_metadata = False def do_layout(self): self.central_widget.clear() @@ -756,13 +793,11 @@ class MetadataSingleDialogAlt2(MetadataSingleDialogBase): # {{{ l.addWidget(gb, 0, 0, 1, 1) gb.setLayout(tl) - self.button_box.addButton(self.fetch_metadata_button, - QDialogButtonBox.ActionRole) - self.config_metadata_button.setToolButtonStyle(Qt.ToolButtonTextOnly) - self.config_metadata_button.setText(_('Configure metadata downloading')) - self.button_box.addButton(self.config_metadata_button, - QDialogButtonBox.ActionRole) - sto(self.button_box, self.title) + self.button_box_layout.insertWidget(1, self.fetch_metadata_button) + self.button_box_layout.insertWidget(2, self.config_metadata_button) + sto(self.button_box, self.fetch_metadata_button) + sto(self.fetch_metadata_button, self.config_metadata_button) + sto(self.config_metadata_button, self.title) def create_row(row, widget, tab_to, button=None, icon=None, span=1): ql = BuddyLabel(widget) @@ -780,6 +815,8 @@ class MetadataSingleDialogAlt2(MetadataSingleDialogBase): # {{{ sto(widget, tab_to) tl.addWidget(self.swap_title_author_button, 0, 0, 2, 1) + tl.addWidget(self.manage_authors_button, 2, 0, 2, 1) + tl.addWidget(self.paste_isbn_button, 11, 0, 1, 1) create_row(0, self.title, self.title_sort, button=self.deduce_title_sort_button, span=2, @@ -801,6 +838,9 @@ class MetadataSingleDialogAlt2(MetadataSingleDialogBase): # {{{ button=self.timestamp.clear_button, icon='trash.png') create_row(11, self.identifiers, self.comments, button=self.clear_identifiers_button, icon='trash.png') + sto(self.clear_identifiers_button, self.swap_title_author_button) + sto(self.swap_title_author_button, self.manage_authors_button) + sto(self.manage_authors_button, self.paste_isbn_button) tl.addItem(QSpacerItem(1, 1, QSizePolicy.Fixed, QSizePolicy.Expanding), 12, 1, 1 ,1) @@ -820,7 +860,7 @@ class MetadataSingleDialogAlt2(MetadataSingleDialogBase): # {{{ l.addWidget(gb, 0, 1, 1, 1) sp = QSizePolicy() sp.setVerticalStretch(10) - sp.setHorizontalPolicy(QSizePolicy.Fixed) + sp.setHorizontalPolicy(QSizePolicy.Minimum) sp.setVerticalPolicy(QSizePolicy.Expanding) gb.setSizePolicy(sp) self.set_custom_metadata_tab_order() @@ -842,7 +882,7 @@ class MetadataSingleDialogAlt2(MetadataSingleDialogBase): # {{{ lb = QGridLayout() gb.setLayout(lb) lb.addWidget(self.cover, 0, 0, 1, 3, alignment=Qt.AlignCenter) - sto(self.clear_identifiers_button, self.cover.buttons[0]) + sto(self.manage_authors_button, self.cover.buttons[0]) for i, b in enumerate(self.cover.buttons[:3]): lb.addWidget(b, 1, i, 1, 1) sto(b, self.cover.buttons[i+1]) diff --git a/src/calibre/library/catalog.py b/src/calibre/library/catalog.py index 8c1f35f579..a19534191b 100644 --- a/src/calibre/library/catalog.py +++ b/src/calibre/library/catalog.py @@ -27,7 +27,7 @@ from calibre.utils.logging import default_log as log from calibre.utils.magick.draw import thumbnail from calibre.utils.zipfile import ZipFile, ZipInfo -FIELDS = ['all', 'title', 'author_sort', 'authors', 'comments', +FIELDS = ['all', 'title', 'title_sort', 'author_sort', 'authors', 'comments', 'cover', 'formats','id', 'isbn', 'ondevice', 'pubdate', 'publisher', 'rating', 'series_index', 'series', 'size', 'tags', 'timestamp', 'uuid'] @@ -66,7 +66,7 @@ class CSV_XML(CatalogPlugin): # {{{ dest = 'sort_by', action = None, help = _('Output field to sort on.\n' - 'Available fields: author_sort, id, rating, size, timestamp, title.\n' + 'Available fields: author_sort, id, rating, size, timestamp, title_sort\n' "Default: '%default'\n" "Applies to: CSV, XML output formats"))] @@ -76,7 +76,7 @@ class CSV_XML(CatalogPlugin): # {{{ if opts.verbose: opts_dict = vars(opts) - log("%s(): Generating %s" % (self.name,self.fmt)) + log("%s(): Generating %s" % (self.name,self.fmt.upper())) if opts.connected_device['is_device_connected']: log(" connected_device: %s" % opts.connected_device['name']) if opts_dict['search_text']: @@ -126,8 +126,11 @@ class CSV_XML(CatalogPlugin): # {{{ for field in fields: if field.startswith('#'): item = db.get_field(entry['id'],field,index_is_id=True) + elif field == 'title_sort': + item = entry['sort'] else: item = entry[field] + if item is None: outstr.append('""') continue @@ -167,7 +170,7 @@ class CSV_XML(CatalogPlugin): # {{{ item = getattr(E, field.replace('#','_'))(val) record.append(item) - for field in ('id', 'uuid', 'title', 'publisher', 'rating', 'size', + for field in ('id', 'uuid', 'publisher', 'rating', 'size', 'isbn','ondevice'): if field in fields: val = r[field] @@ -178,6 +181,10 @@ class CSV_XML(CatalogPlugin): # {{{ item = getattr(E, field)(val) record.append(item) + if 'title' in fields: + title = E.title(r['title'], sort=r['sort']) + record.append(title) + if 'authors' in fields: aus = E.authors(sort=r['author_sort']) for au in r['authors']: diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index ac36335b79..8ac33d4b40 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -3056,7 +3056,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): ''' if prefix is None: prefix = self.library_path - FIELDS = set(['title', 'authors', 'author_sort', 'publisher', 'rating', + FIELDS = set(['title', 'sort', 'authors', 'author_sort', 'publisher', 'rating', 'timestamp', 'size', 'tags', 'comments', 'series', 'series_index', 'uuid', 'pubdate', 'last_modified', 'identifiers']) for x in self.custom_column_num_map: diff --git a/src/calibre/utils/titlecase.py b/src/calibre/utils/titlecase.py index 1f153dd5fe..ff5b446268 100755 --- a/src/calibre/utils/titlecase.py +++ b/src/calibre/utils/titlecase.py @@ -10,6 +10,7 @@ License: http://www.opensource.org/licenses/mit-license.php import re from calibre.utils.icu import capitalize +from calibre.utils.config import prefs __all__ = ['titlecase'] __version__ = '0.5' @@ -67,11 +68,12 @@ def titlecase(text): line.append(icu_lower(word)) continue - match = MAC_MC.match(word) - if match and not match.group(2)[:3] in ('hin', 'ht'): - line.append("%s%s" % (capitalize(match.group(1)), - capitalize(match.group(2)))) - continue + if prefs['language'].lower().startswith('en'): + match = MAC_MC.match(word) + if match and not match.group(2)[:3] in ('hin', 'ht'): + line.append("%s%s" % (capitalize(match.group(1)), + capitalize(match.group(2)))) + continue hyphenated = [] for item in word.split('-'):