Added/fixed translation strings, removed most of the remaining @property decorators.

This commit is contained in:
GRiker 2012-09-07 14:07:41 -06:00
parent 4183aedf9f
commit 3a584f406e
3 changed files with 59 additions and 165 deletions

View File

@ -87,7 +87,7 @@ class PluginWidget(QWidget,Ui_Form):
option_fields += zip(['exclusion_rules_tw'], option_fields += zip(['exclusion_rules_tw'],
[{'ordinal':0, [{'ordinal':0,
'enabled':True, 'enabled':True,
'name':'Catalogs', 'name':_('Catalogs'),
'field':'Tags', 'field':'Tags',
'pattern':'Catalog'},], 'pattern':'Catalog'},],
['table_widget']) ['table_widget'])
@ -96,13 +96,13 @@ class PluginWidget(QWidget,Ui_Form):
option_fields += zip(['prefix_rules_tw','prefix_rules_tw'], option_fields += zip(['prefix_rules_tw','prefix_rules_tw'],
[{'ordinal':0, [{'ordinal':0,
'enabled':True, 'enabled':True,
'name':'Read book', 'name':_('Read book'),
'field':'Tags', 'field':'Tags',
'pattern':'+', 'pattern':'+',
'prefix':u'\u2713'}, 'prefix':u'\u2713'},
{'ordinal':1, {'ordinal':1,
'enabled':True, 'enabled':True,
'name':'Wishlist item', 'name':_('Wishlist item'),
'field':'Tags', 'field':'Tags',
'pattern':'Wishlist', 'pattern':'Wishlist',
'prefix':u'\u00d7'},], 'prefix':u'\u00d7'},],

View File

@ -59,7 +59,7 @@ class EPUB_MOBI(CatalogPlugin):
"Applies to: AZW3, ePub, MOBI output formats")), "Applies to: AZW3, ePub, MOBI output formats")),
Option('--exclusion-rules', Option('--exclusion-rules',
default="(('Excluded tags','Tags','Catalog'),)", default="(('Catalogs','Tags','Catalog'),)",
dest='exclusion_rules', dest='exclusion_rules',
action=None, action=None,
help=_("Specifies the rules used to exclude books from the generated catalog.\n" help=_("Specifies the rules used to exclude books from the generated catalog.\n"
@ -139,7 +139,7 @@ class EPUB_MOBI(CatalogPlugin):
"Default: '%default'\n" "Default: '%default'\n"
"Applies to: AZW3, ePub, MOBI output formats")), "Applies to: AZW3, ePub, MOBI output formats")),
Option('--prefix-rules', Option('--prefix-rules',
default="(('Read books','tags','+','\u2713'),('Wishlist items','tags','Wishlist','\u00d7'))", default="(('Read books','tags','+','\u2713'),('Wishlist item','tags','Wishlist','\u00d7'))",
dest='prefix_rules', dest='prefix_rules',
action=None, action=None,
help=_("Specifies the rules used to include prefixes indicating read books, wishlist items and other user-specified prefixes.\n" help=_("Specifies the rules used to include prefixes indicating read books, wishlist items and other user-specified prefixes.\n"

View File

@ -55,199 +55,93 @@ class CatalogBuilder(object):
# title dc:title in OPF metadata, NCX periodical # title dc:title in OPF metadata, NCX periodical
# verbosity level of diagnostic printout # verbosity level of diagnostic printout
""" property decorators for attributes """ ''' device-specific symbol (default empty star) '''
if True: @property
''' directory to store cached thumbs ''' def SYMBOL_EMPTY_RATING(self):
@property return self.output_profile.empty_ratings_char
def cache_dir(self):
return self.__cache_dir
''' temp dir to store generated catalog ''' ''' device-specific symbol (default filled star) '''
@property @property
def catalog_path(self): def SYMBOL_FULL_RATING(self):
return self.__catalog_path return self.output_profile.ratings_char
''' content dir in generated catalog ''' ''' device-specific symbol for reading progress '''
@property @property
def content_dir(self): def SYMBOL_PROGRESS_READ(self):
return self.__content_dir psr = '+'
if self.generate_for_kindle:
psr = '▪'
return psr
''' device-specific symbol for reading progress '''
@property
def SYMBOL_PROGRESS_UNREAD(self):
psu = '-'
if self.generate_for_kindle:
psu = '▫'
return psu
''' active database ''' ''' device-specific symbol for reading progress '''
@property @property
def db(self): def SYMBOL_READING(self):
return self.__db if self.generate_for_kindle:
return self.format_prefix('▷')
else:
return self.format_prefix(' ')
''' tags to exclude as genres '''
@property
def excluded_tags(self):
return self.__excluded_tags
''' True if generating for Kindle in MOBI format '''
@property
def generate_for_kindle(self):
return self.__generate_for_kindle
''' True if connected Kindle and generating for Kindle '''
@property
def generate_recently_read(self):
return self.__generate_recently_read
''' additional field to include before/after comments '''
@property
def merge_comments_rule(self):
return self.__merge_comments_rule
''' opts passed from gui2.catalog.catalog_epub_mobi.py '''
@property
def opts(self):
return self.__opts
''' output_profile declares special symbols '''
@property
def output_profile(self):
return self.__output_profile
''' catalog??? device??? '''
@property
def plugin(self):
return self.__plugin
''' Progress Reporter for Jobs '''
@property
def reporter(self):
return self.__reporter
''' stylesheet to include with catalog '''
@property
def stylesheet(self):
return self.__stylesheet
''' device-specific symbol (default empty star) '''
@property
def SYMBOL_EMPTY_RATING(self):
return self.output_profile.empty_ratings_char
''' device-specific symbol (default filled star) '''
@property
def SYMBOL_FULL_RATING(self):
return self.output_profile.ratings_char
''' device-specific symbol for reading progress '''
@property
def SYMBOL_PROGRESS_READ(self):
psr = '+'
if self.generate_for_kindle:
psr = '▪'
return psr
''' device-specific symbol for reading progress '''
@property
def SYMBOL_PROGRESS_UNREAD(self):
psu = '-'
if self.generate_for_kindle:
psu = '▫'
return psu
''' device-specific symbol for reading progress '''
@property
def SYMBOL_READING(self):
if self.generate_for_kindle:
return self.format_prefix('▷')
else:
return self.format_prefix(' ')
''' full path to thumbs archive '''
@property
def thumbs_path(self):
return self.__thumbs_path
''' switch controlling format of series books in Titles section '''
@property
def use_series_prefix_in_titles_section(self):
return self.__use_series_prefix_in_titles_section
def __init__(self, db, _opts, plugin, def __init__(self, db, _opts, plugin,
report_progress=DummyReporter(), report_progress=DummyReporter(),
stylesheet="content/stylesheet.css", stylesheet="content/stylesheet.css",
init_resources=True): init_resources=True):
self.__db = db self.db = db
self.__opts = _opts self.opts = _opts
self.__plugin = plugin self.plugin = plugin
self.__reporter = report_progress self.reporter = report_progress
self.__stylesheet = stylesheet self.stylesheet = stylesheet
self.__cache_dir = os.path.join(config_dir, 'caches', 'catalog') self.cache_dir = os.path.join(config_dir, 'caches', 'catalog')
self.__catalog_path = PersistentTemporaryDirectory("_epub_mobi_catalog", prefix='') self.catalog_path = PersistentTemporaryDirectory("_epub_mobi_catalog", prefix='')
self.__excluded_tags = self.get_excluded_tags() self.excluded_tags = self.get_excluded_tags()
self.__generate_for_kindle = True if (_opts.fmt == 'mobi' and self.generate_for_kindle = True if (_opts.fmt == 'mobi' and
_opts.output_profile and _opts.output_profile and
_opts.output_profile.startswith("kindle")) else False _opts.output_profile.startswith("kindle")) else False
''' list of unique authors '''
self.authors = None self.authors = None
''' dict of bookmarked books '''
self.bookmarked_books = None self.bookmarked_books = None
''' list of bookmarked books, sorted by date read '''
self.bookmarked_books_by_date_read = None self.bookmarked_books_by_date_read = None
''' list of books, sorted by author '''
self.books_by_author = None self.books_by_author = None
''' list of books, grouped by date range (30 days) '''
self.books_by_date_range = None self.books_by_date_range = None
''' list of books, by date added reverse (most recent first) '''
self.books_by_month = None self.books_by_month = None
''' list of books in series '''
self.books_by_series = None self.books_by_series = None
''' list of books, sorted by title '''
self.books_by_title = None self.books_by_title = None
''' list of books in series, without series prefix '''
self.books_by_title_no_series_prefix = None self.books_by_title_no_series_prefix = None
''' Initial list of books to catalog from which all sections are built '''
self.books_to_catalog = None self.books_to_catalog = None
self.__content_dir = os.path.join(self.catalog_path, "content") self.content_dir = os.path.join(self.catalog_path, "content")
''' track Job progress '''
self.current_step = 0.0 self.current_step = 0.0
''' cumulative error messages to report at conclusion '''
self.error = [] self.error = []
self.__generate_recently_read = True if (_opts.generate_recently_added and self.generate_recently_read = True if (_opts.generate_recently_added and
_opts.connected_kindle and _opts.connected_kindle and
self.generate_for_kindle) else False self.generate_for_kindle) else False
''' list of dicts with books by genre '''
self.genres = [] self.genres = []
''' dict of enabled genre tags '''
self.genre_tags_dict = None self.genre_tags_dict = None
''' Author, Title, Series sections '''
self.html_filelist_1 = [] self.html_filelist_1 = []
''' Date Added, Date Read '''
self.html_filelist_2 = [] self.html_filelist_2 = []
self.__merge_comments_rule = dict(zip(['field','position','hr'],_opts.merge_comments_rule.split(':'))) self.merge_comments_rule = dict(zip(['field','position','hr'],
''' cumulative HTML for NCX file ''' _opts.merge_comments_rule.split(':')))
self.ncx_soup = None self.ncx_soup = None
self.__output_profile = None self.output_profile = None
self.__output_profile = self.get_output_profile(_opts) self.output_profile = self.get_output_profile(_opts)
''' playOrder value for building NCX '''
self.play_order = 1 self.play_order = 1
''' dict of prefix rules '''
self.prefix_rules = self.get_prefix_rules() self.prefix_rules = self.get_prefix_rules()
''' used with ProgressReporter() '''
self.progress_int = 0.0 self.progress_int = 0.0
''' used with ProgressReporter() '''
self.progress_string = '' self.progress_string = ''
self.thumb_height = 0
self.__thumb_height = 0 self.thumb_width = 0
self.__thumb_width = 0
''' list of generated thumbs '''
self.thumbs = None self.thumbs = None
self.__thumbs_path = os.path.join(self.cache_dir, "thumbs.zip") self.thumbs_path = os.path.join(self.cache_dir, "thumbs.zip")
''' used with ProgressReporter() '''
self.total_steps = 6.0 self.total_steps = 6.0
self.__use_series_prefix_in_titles_section = False self.use_series_prefix_in_titles_section = False
self.books_to_catalog = self.fetch_books_to_catalog() self.books_to_catalog = self.fetch_books_to_catalog()
self.compute_total_steps() self.compute_total_steps()
@ -3141,8 +3035,8 @@ class CatalogBuilder(object):
self.play_order += 1 self.play_order += 1
navLabelTag = Tag(soup, 'navLabel') navLabelTag = Tag(soup, 'navLabel')
textTag = Tag(soup, 'text') textTag = Tag(soup, 'text')
textTag.insert(0, NavigableString(_(u"Series beginning with %s") % \ textTag.insert(0, NavigableString(_(u"Series beginning with '%s'") % \
(title_letters[i] if len(title_letters[i])>1 else "'" + title_letters[i] + "'"))) (title_letters[i] if len(title_letters[i])>1 else title_letters[i])))
navLabelTag.insert(0, textTag) navLabelTag.insert(0, textTag)
navPointByLetterTag.insert(0,navLabelTag) navPointByLetterTag.insert(0,navLabelTag)
contentTag = Tag(soup, 'content') contentTag = Tag(soup, 'content')
@ -3262,8 +3156,8 @@ class CatalogBuilder(object):
self.play_order += 1 self.play_order += 1
navLabelTag = Tag(soup, 'navLabel') navLabelTag = Tag(soup, 'navLabel')
textTag = Tag(soup, 'text') textTag = Tag(soup, 'text')
textTag.insert(0, NavigableString(_(u"Titles beginning with %s") % \ textTag.insert(0, NavigableString(_(u"Titles beginning with '%s'") % \
(title_letters[i] if len(title_letters[i])>1 else "'" + title_letters[i] + "'"))) (title_letters[i] if len(title_letters[i])>1 else title_letters[i])))
navLabelTag.insert(0, textTag) navLabelTag.insert(0, textTag)
navPointByLetterTag.insert(0,navLabelTag) navPointByLetterTag.insert(0,navLabelTag)
contentTag = Tag(soup, 'content') contentTag = Tag(soup, 'content')