Removed unnecessary Unicode "u"
This commit is contained in:
parent
8022b1bb36
commit
43ee85fbb5
12
cps/admin.py
12
cps/admin.py
|
@ -145,9 +145,9 @@ def shutdown():
|
|||
ub.dispose()
|
||||
|
||||
if task == 0:
|
||||
show_text['text'] = _(u'Server restarted, please reload page.')
|
||||
show_text['text'] = _('Server restarted, please reload page.')
|
||||
else:
|
||||
show_text['text'] = _(u'Performing Server shutdown, please close window.')
|
||||
show_text['text'] = _('Performing Server shutdown, please close window.')
|
||||
# stop gevent/tornado server
|
||||
web_server.stop(task == 0)
|
||||
return json.dumps(show_text)
|
||||
|
@ -155,10 +155,10 @@ def shutdown():
|
|||
if task == 2:
|
||||
log.warning("reconnecting to calibre database")
|
||||
calibre_db.reconnect_db(config, ub.app_DB_path)
|
||||
show_text['text'] = _(u'Success! Database Reconnected')
|
||||
show_text['text'] = _('Success! Database Reconnected')
|
||||
return json.dumps(show_text)
|
||||
|
||||
show_text['text'] = _(u'Unknown command')
|
||||
show_text['text'] = _('Unknown command')
|
||||
return json.dumps(show_text), 400
|
||||
|
||||
|
||||
|
@ -169,7 +169,7 @@ def queue_metadata_backup():
|
|||
show_text = {}
|
||||
log.warning("Queuing all books for metadata backup")
|
||||
helper.set_all_metadata_dirty()
|
||||
show_text['text'] = _(u'Success! Books queued for Metadata Backup')
|
||||
show_text['text'] = _('Success! Books queued for Metadata Backup')
|
||||
return json.dumps(show_text)
|
||||
|
||||
|
||||
|
@ -202,7 +202,7 @@ def update_thumbnails():
|
|||
def admin():
|
||||
version = updater_thread.get_current_version_info()
|
||||
if version is False:
|
||||
commit = _(u'Unknown')
|
||||
commit = _('Unknown')
|
||||
else:
|
||||
if 'datetime' in version:
|
||||
commit = version['datetime']
|
||||
|
|
|
@ -138,7 +138,7 @@ def get_comic_info(tmp_file_path, original_file_name, original_file_extension, r
|
|||
file_path=tmp_file_path,
|
||||
extension=original_file_extension,
|
||||
title=original_file_name,
|
||||
author=u'Unknown',
|
||||
author='Unknown',
|
||||
cover=_extract_cover(tmp_file_path, original_file_extension, rar_executable),
|
||||
description="",
|
||||
tags="",
|
||||
|
|
|
@ -69,7 +69,7 @@ class _Settings(_Base):
|
|||
config_certfile = Column(String)
|
||||
config_keyfile = Column(String)
|
||||
config_trustedhosts = Column(String, default='')
|
||||
config_calibre_web_title = Column(String, default=u'Calibre-Web')
|
||||
config_calibre_web_title = Column(String, default='Calibre-Web')
|
||||
config_books_per_page = Column(Integer, default=60)
|
||||
config_random_books = Column(Integer, default=4)
|
||||
config_authors_max = Column(Integer, default=0)
|
||||
|
|
18
cps/db.py
18
cps/db.py
|
@ -192,7 +192,7 @@ class Comments(Base):
|
|||
return self.text
|
||||
|
||||
def __repr__(self):
|
||||
return u"<Comments({0})>".format(self.text)
|
||||
return "<Comments({0})>".format(self.text)
|
||||
|
||||
|
||||
class Tags(Base):
|
||||
|
@ -208,7 +208,7 @@ class Tags(Base):
|
|||
return self.name
|
||||
|
||||
def __repr__(self):
|
||||
return u"<Tags('{0})>".format(self.name)
|
||||
return "<Tags('{0})>".format(self.name)
|
||||
|
||||
|
||||
class Authors(Base):
|
||||
|
@ -228,7 +228,7 @@ class Authors(Base):
|
|||
return self.name
|
||||
|
||||
def __repr__(self):
|
||||
return u"<Authors('{0},{1}{2}')>".format(self.name, self.sort, self.link)
|
||||
return "<Authors('{0},{1}{2}')>".format(self.name, self.sort, self.link)
|
||||
|
||||
|
||||
class Series(Base):
|
||||
|
@ -246,7 +246,7 @@ class Series(Base):
|
|||
return self.name
|
||||
|
||||
def __repr__(self):
|
||||
return u"<Series('{0},{1}')>".format(self.name, self.sort)
|
||||
return "<Series('{0},{1}')>".format(self.name, self.sort)
|
||||
|
||||
|
||||
class Ratings(Base):
|
||||
|
@ -262,7 +262,7 @@ class Ratings(Base):
|
|||
return self.rating
|
||||
|
||||
def __repr__(self):
|
||||
return u"<Ratings('{0}')>".format(self.rating)
|
||||
return "<Ratings('{0}')>".format(self.rating)
|
||||
|
||||
|
||||
class Languages(Base):
|
||||
|
@ -281,7 +281,7 @@ class Languages(Base):
|
|||
return self.lang_code
|
||||
|
||||
def __repr__(self):
|
||||
return u"<Languages('{0}')>".format(self.lang_code)
|
||||
return "<Languages('{0}')>".format(self.lang_code)
|
||||
|
||||
|
||||
class Publishers(Base):
|
||||
|
@ -299,7 +299,7 @@ class Publishers(Base):
|
|||
return self.name
|
||||
|
||||
def __repr__(self):
|
||||
return u"<Publishers('{0},{1}')>".format(self.name, self.sort)
|
||||
return "<Publishers('{0},{1}')>".format(self.name, self.sort)
|
||||
|
||||
|
||||
class Data(Base):
|
||||
|
@ -323,7 +323,7 @@ class Data(Base):
|
|||
return self.name
|
||||
|
||||
def __repr__(self):
|
||||
return u"<Data('{0},{1}{2}{3}')>".format(self.book, self.format, self.uncompressed_size, self.name)
|
||||
return "<Data('{0},{1}{2}{3}')>".format(self.book, self.format, self.uncompressed_size, self.name)
|
||||
|
||||
|
||||
class Metadata_Dirtied(Base):
|
||||
|
@ -377,7 +377,7 @@ class Books(Base):
|
|||
self.has_cover = (has_cover != None)
|
||||
|
||||
def __repr__(self):
|
||||
return u"<Books('{0},{1}{2}{3}{4}{5}{6}{7}{8}')>".format(self.title, self.sort, self.author_sort,
|
||||
return "<Books('{0},{1}{2}{3}{4}{5}{6}{7}{8}')>".format(self.title, self.sort, self.author_sort,
|
||||
self.timestamp, self.pubdate, self.series_index,
|
||||
self.last_modified, self.path, self.has_cover)
|
||||
|
||||
|
|
|
@ -573,9 +573,9 @@ def table_xchange_author_title():
|
|||
|
||||
|
||||
def merge_metadata(to_save, meta):
|
||||
if to_save.get('author_name', "") == _(u'Unknown'):
|
||||
if to_save.get('author_name', "") == _('Unknown'):
|
||||
to_save['author_name'] = ''
|
||||
if to_save.get('book_title', "") == _(u'Unknown'):
|
||||
if to_save.get('book_title', "") == _('Unknown'):
|
||||
to_save['book_title'] = ''
|
||||
for s_field, m_field in [
|
||||
('tags', 'tags'), ('author_name', 'author'), ('series', 'series'),
|
||||
|
@ -611,7 +611,7 @@ def prepare_authors(authr):
|
|||
|
||||
# we have all author names now
|
||||
if input_authors == ['']:
|
||||
input_authors = [_(u'Unknown')] # prevent empty Author
|
||||
input_authors = [_('Unknown')] # prevent empty Author
|
||||
|
||||
renamed = list()
|
||||
for in_aut in input_authors:
|
||||
|
@ -628,7 +628,7 @@ def prepare_authors(authr):
|
|||
|
||||
|
||||
def prepare_authors_on_upload(title, authr):
|
||||
if title != _(u'Unknown') and authr != _(u'Unknown'):
|
||||
if title != _('Unknown') and authr != _('Unknown'):
|
||||
entry = calibre_db.check_exists_book(authr, title)
|
||||
if entry:
|
||||
log.info("Uploaded book probably exists in library")
|
||||
|
@ -771,7 +771,7 @@ def delete_whole_book(book_id, book):
|
|||
|
||||
# check if only this book links to:
|
||||
# author, language, series, tags, custom columns
|
||||
modify_database_object([u''], book.authors, db.Authors, calibre_db.session, 'author')
|
||||
modify_database_object([''], book.authors, db.Authors, calibre_db.session, 'author')
|
||||
modify_database_object([u''], book.tags, db.Tags, calibre_db.session, 'tags')
|
||||
modify_database_object([u''], book.series, db.Series, calibre_db.session, 'series')
|
||||
modify_database_object([u''], book.languages, db.Languages, calibre_db.session, 'languages')
|
||||
|
|
|
@ -80,13 +80,13 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension):
|
|||
if epub_metadata['subject'] == 'Unknown':
|
||||
epub_metadata['subject'] = ''
|
||||
|
||||
if epub_metadata['publisher'] == u'Unknown':
|
||||
if epub_metadata['publisher'] == 'Unknown':
|
||||
epub_metadata['publisher'] = ''
|
||||
|
||||
if epub_metadata['date'] == u'Unknown':
|
||||
if epub_metadata['date'] == 'Unknown':
|
||||
epub_metadata['date'] = ''
|
||||
|
||||
if epub_metadata['description'] == u'Unknown':
|
||||
if epub_metadata['description'] == 'Unknown':
|
||||
description = tree.xpath("//*[local-name() = 'description']/text()")
|
||||
if len(description) > 0:
|
||||
epub_metadata['description'] = description
|
||||
|
|
14
cps/fb2.py
14
cps/fb2.py
|
@ -38,19 +38,19 @@ def get_fb2_info(tmp_file_path, original_file_extension):
|
|||
if len(last_name):
|
||||
last_name = last_name[0]
|
||||
else:
|
||||
last_name = u''
|
||||
last_name = ''
|
||||
middle_name = element.xpath('fb:middle-name/text()', namespaces=ns)
|
||||
if len(middle_name):
|
||||
middle_name = middle_name[0]
|
||||
else:
|
||||
middle_name = u''
|
||||
middle_name = ''
|
||||
first_name = element.xpath('fb:first-name/text()', namespaces=ns)
|
||||
if len(first_name):
|
||||
first_name = first_name[0]
|
||||
else:
|
||||
first_name = u''
|
||||
return (first_name + u' '
|
||||
+ middle_name + u' '
|
||||
first_name = ''
|
||||
return (first_name + ' '
|
||||
+ middle_name + ' '
|
||||
+ last_name)
|
||||
|
||||
author = str(", ".join(map(get_author, authors)))
|
||||
|
@ -59,12 +59,12 @@ def get_fb2_info(tmp_file_path, original_file_extension):
|
|||
if len(title):
|
||||
title = str(title[0])
|
||||
else:
|
||||
title = u''
|
||||
title = ''
|
||||
description = tree.xpath('/fb:FictionBook/fb:description/fb:publish-info/fb:book-name/text()', namespaces=ns)
|
||||
if len(description):
|
||||
description = str(description[0])
|
||||
else:
|
||||
description = u''
|
||||
description = ''
|
||||
|
||||
return BookMeta(
|
||||
file_path=tmp_file_path,
|
||||
|
|
|
@ -55,7 +55,7 @@ def authenticate_google_drive():
|
|||
try:
|
||||
authUrl = gdriveutils.Gauth.Instance().auth.GetAuthUrl()
|
||||
except gdriveutils.InvalidConfigError:
|
||||
flash(_(u'Google Drive setup not completed, try to deactivate and activate Google Drive again'),
|
||||
flash(_('Google Drive setup not completed, try to deactivate and activate Google Drive again'),
|
||||
category="error")
|
||||
return redirect(url_for('web.index'))
|
||||
return redirect(authUrl)
|
||||
|
@ -91,9 +91,9 @@ def watch_gdrive():
|
|||
config.save()
|
||||
except HttpError as e:
|
||||
reason=json.loads(e.content)['error']['errors'][0]
|
||||
if reason['reason'] == u'push.webhookUrlUnauthorized':
|
||||
flash(_(u'Callback domain is not verified, '
|
||||
u'please follow steps to verify domain in google developer console'), category="error")
|
||||
if reason['reason'] == 'push.webhookUrlUnauthorized':
|
||||
flash(_('Callback domain is not verified, '
|
||||
'please follow steps to verify domain in google developer console'), category="error")
|
||||
else:
|
||||
flash(reason['message'], category="error")
|
||||
|
||||
|
|
|
@ -556,7 +556,7 @@ def updateGdriveCalibreFromLocal():
|
|||
|
||||
# update gdrive.db on edit of books title
|
||||
def updateDatabaseOnEdit(ID,newPath):
|
||||
sqlCheckPath = newPath if newPath[-1] == '/' else newPath + u'/'
|
||||
sqlCheckPath = newPath if newPath[-1] == '/' else newPath + '/'
|
||||
storedPathName = session.query(GdriveId).filter(GdriveId.gdrive_id == ID).first()
|
||||
if storedPathName:
|
||||
storedPathName.path = sqlCheckPath
|
||||
|
|
|
@ -95,11 +95,11 @@ def convert_book_format(book_id, calibre_path, old_book_format, new_book_format,
|
|||
if ereader_mail:
|
||||
settings = config.get_mail_settings()
|
||||
settings['subject'] = _('Send to eReader') # pretranslate Subject for Email
|
||||
settings['body'] = _(u'This Email has been sent via Calibre-Web.')
|
||||
settings['body'] = _('This Email has been sent via Calibre-Web.')
|
||||
else:
|
||||
settings = dict()
|
||||
link = '<a href="{}">{}</a>'.format(url_for('web.show_book', book_id=book.id), escape(book.title)) # prevent xss
|
||||
txt = u"{} -> {}: {}".format(
|
||||
txt = "{} -> {}: {}".format(
|
||||
old_book_format.upper(),
|
||||
new_book_format.upper(),
|
||||
link)
|
||||
|
@ -111,9 +111,9 @@ def convert_book_format(book_id, calibre_path, old_book_format, new_book_format,
|
|||
|
||||
# Texts are not lazy translated as they are supposed to get send out as is
|
||||
def send_test_mail(ereader_mail, user_name):
|
||||
WorkerThread.add(user_name, TaskEmail(_(u'Calibre-Web Test Email'), None, None,
|
||||
WorkerThread.add(user_name, TaskEmail(_('Calibre-Web Test Email'), None, None,
|
||||
config.get_mail_settings(), ereader_mail, N_("Test Email"),
|
||||
_(u'This Email has been sent via Calibre-Web.')))
|
||||
_('This Email has been sent via Calibre-Web.')))
|
||||
return
|
||||
|
||||
|
||||
|
@ -129,7 +129,7 @@ def send_registration_mail(e_mail, user_name, default_password, resend=False):
|
|||
txt += "Regards,\r\n\r\n"
|
||||
txt += "Calibre-Web"
|
||||
WorkerThread.add(None, TaskEmail(
|
||||
subject=_(u'Get Started with Calibre-Web'),
|
||||
subject=_('Get Started with Calibre-Web'),
|
||||
filepath=None,
|
||||
attachment=None,
|
||||
settings=config.get_mail_settings(),
|
||||
|
@ -187,7 +187,7 @@ def check_send_to_ereader(entry):
|
|||
book_formats.extend(check_send_to_ereader_with_converter(formats))
|
||||
return book_formats
|
||||
else:
|
||||
log.error(u'Cannot find book entry %d', entry.id)
|
||||
log.error('Cannot find book entry %d', entry.id)
|
||||
return None
|
||||
|
||||
|
||||
|
@ -213,10 +213,10 @@ def send_mail(book_id, book_format, convert, ereader_mail, calibrepath, user_id)
|
|||
|
||||
if convert == 1:
|
||||
# returns None if success, otherwise errormessage
|
||||
return convert_book_format(book_id, calibrepath, u'epub', book_format.lower(), user_id, ereader_mail)
|
||||
return convert_book_format(book_id, calibrepath, 'epub', book_format.lower(), user_id, ereader_mail)
|
||||
if convert == 2:
|
||||
# returns None if success, otherwise errormessage
|
||||
return convert_book_format(book_id, calibrepath, u'azw3', book_format.lower(), user_id, ereader_mail)
|
||||
return convert_book_format(book_id, calibrepath, 'azw3', book_format.lower(), user_id, ereader_mail)
|
||||
|
||||
for entry in iter(book.data):
|
||||
if entry.format.upper() == book_format.upper():
|
||||
|
@ -225,7 +225,7 @@ def send_mail(book_id, book_format, convert, ereader_mail, calibrepath, user_id)
|
|||
email_text = N_("%(book)s send to eReader", book=link)
|
||||
WorkerThread.add(user_id, TaskEmail(_("Send to eReader"), book.path, converted_file_name,
|
||||
config.get_mail_settings(), ereader_mail,
|
||||
email_text, _(u'This Email has been sent via Calibre-Web.')))
|
||||
email_text, _('This Email has been sent via Calibre-Web.')))
|
||||
return
|
||||
return _("The requested file could not be read. Maybe wrong permissions?")
|
||||
|
||||
|
@ -235,16 +235,16 @@ def get_valid_filename(value, replace_whitespace=True, chars=128):
|
|||
Returns the given string converted to a string that can be used for a clean
|
||||
filename. Limits num characters to 128 max.
|
||||
"""
|
||||
if value[-1:] == u'.':
|
||||
value = value[:-1]+u'_'
|
||||
if value[-1:] == '.':
|
||||
value = value[:-1]+'_'
|
||||
value = value.replace("/", "_").replace(":", "_").strip('\0')
|
||||
if config.config_unicode_filename:
|
||||
value = (unidecode.unidecode(value))
|
||||
if replace_whitespace:
|
||||
# *+:\"/<>? are replaced by _
|
||||
value = re.sub(r'[*+:\\\"/<>?]+', u'_', value, flags=re.U)
|
||||
value = re.sub(r'[*+:\\\"/<>?]+', '_', value, flags=re.U)
|
||||
# pipe has to be replaced with comma
|
||||
value = re.sub(r'[|]+', u',', value, flags=re.U)
|
||||
value = re.sub(r'[|]+', ',', value, flags=re.U)
|
||||
|
||||
value = value.encode('utf-8')[:chars].decode('utf-8', errors='ignore').strip()
|
||||
|
||||
|
@ -416,8 +416,8 @@ def clean_author_database(renamed_author, calibre_path="", local_book=None, gdri
|
|||
g_file = gd.getFileFromEbooksFolder(all_new_path,
|
||||
file_format.name + '.' + file_format.format.lower())
|
||||
if g_file:
|
||||
gd.moveGdriveFileRemote(g_file, all_new_name + u'.' + file_format.format.lower())
|
||||
gd.updateDatabaseOnEdit(g_file['id'], all_new_name + u'.' + file_format.format.lower())
|
||||
gd.moveGdriveFileRemote(g_file, all_new_name + '.' + file_format.format.lower())
|
||||
gd.updateDatabaseOnEdit(g_file['id'], all_new_name + '.' + file_format.format.lower())
|
||||
else:
|
||||
log.error("File {} not found on gdrive"
|
||||
.format(all_new_path, file_format.name + '.' + file_format.format.lower()))
|
||||
|
@ -510,25 +510,25 @@ def update_dir_structure_gdrive(book_id, first_author, renamed_author):
|
|||
authordir = book.path.split('/')[0]
|
||||
titledir = book.path.split('/')[1]
|
||||
new_authordir = rename_all_authors(first_author, renamed_author, gdrive=True)
|
||||
new_titledir = get_valid_filename(book.title, chars=96) + u" (" + str(book_id) + u")"
|
||||
new_titledir = get_valid_filename(book.title, chars=96) + " (" + str(book_id) + ")"
|
||||
|
||||
if titledir != new_titledir:
|
||||
g_file = gd.getFileFromEbooksFolder(os.path.dirname(book.path), titledir)
|
||||
if g_file:
|
||||
gd.moveGdriveFileRemote(g_file, new_titledir)
|
||||
book.path = book.path.split('/')[0] + u'/' + new_titledir
|
||||
book.path = book.path.split('/')[0] + '/' + new_titledir
|
||||
gd.updateDatabaseOnEdit(g_file['id'], book.path) # only child folder affected
|
||||
else:
|
||||
return _(u'File %(file)s not found on Google Drive', file=book.path) # file not found
|
||||
return _('File %(file)s not found on Google Drive', file=book.path) # file not found
|
||||
|
||||
if authordir != new_authordir and authordir not in renamed_author:
|
||||
g_file = gd.getFileFromEbooksFolder(os.path.dirname(book.path), new_titledir)
|
||||
if g_file:
|
||||
gd.moveGdriveFolderRemote(g_file, new_authordir)
|
||||
book.path = new_authordir + u'/' + book.path.split('/')[1]
|
||||
book.path = new_authordir + '/' + book.path.split('/')[1]
|
||||
gd.updateDatabaseOnEdit(g_file['id'], book.path)
|
||||
else:
|
||||
return _(u'File %(file)s not found on Google Drive', file=authordir) # file not found
|
||||
return _('File %(file)s not found on Google Drive', file=authordir) # file not found
|
||||
|
||||
# change location in database to new author/title path
|
||||
book.path = os.path.join(new_authordir, new_titledir).replace('\\', '/')
|
||||
|
@ -600,7 +600,7 @@ def delete_book_gdrive(book, book_format):
|
|||
gd.deleteDatabaseEntry(g_file['id'])
|
||||
g_file.Trash()
|
||||
else:
|
||||
error = _(u'Book path %(path)s not found on Google Drive', path=book.path) # file not found
|
||||
error = _('Book path %(path)s not found on Google Drive', path=book.path) # file not found
|
||||
|
||||
return error is None, error
|
||||
|
||||
|
|
|
@ -295,8 +295,8 @@ if ub.oauth_support:
|
|||
@oauth_error.connect_via(oauthblueprints[0]['blueprint'])
|
||||
def github_error(blueprint, error, error_description=None, error_uri=None):
|
||||
msg = (
|
||||
u"OAuth error from {name}! "
|
||||
u"error={error} description={description} uri={uri}"
|
||||
"OAuth error from {name}! "
|
||||
"error={error} description={description} uri={uri}"
|
||||
).format(
|
||||
name=blueprint.name,
|
||||
error=error,
|
||||
|
@ -308,8 +308,8 @@ if ub.oauth_support:
|
|||
@oauth_error.connect_via(oauthblueprints[1]['blueprint'])
|
||||
def google_error(blueprint, error, error_description=None, error_uri=None):
|
||||
msg = (
|
||||
u"OAuth error from {name}! "
|
||||
u"error={error} description={description} uri={uri}"
|
||||
"OAuth error from {name}! "
|
||||
"error={error} description={description} uri={uri}"
|
||||
).format(
|
||||
name=blueprint.name,
|
||||
error=error,
|
||||
|
|
|
@ -328,7 +328,7 @@ def feed_format(book_id):
|
|||
@requires_basic_auth_if_no_ano
|
||||
def feed_languagesindex():
|
||||
off = request.args.get("offset") or 0
|
||||
if current_user.filter_language() == u"all":
|
||||
if current_user.filter_language() == "all":
|
||||
languages = calibre_db.speaking_language()
|
||||
else:
|
||||
languages = calibre_db.session.query(db.Languages).filter(
|
||||
|
|
|
@ -189,14 +189,14 @@ def extend_search_term(searchterm,
|
|||
format_date(datetime.strptime(pub_start, "%Y-%m-%d"),
|
||||
format='medium')])
|
||||
except ValueError:
|
||||
pub_start = u""
|
||||
pub_start = ""
|
||||
if pub_end:
|
||||
try:
|
||||
searchterm.extend([_("Published before ") +
|
||||
format_date(datetime.strptime(pub_end, "%Y-%m-%d"),
|
||||
format='medium')])
|
||||
except ValueError:
|
||||
pub_end = u""
|
||||
pub_end = ""
|
||||
elements = {'tag': db.Tags, 'serie':db.Series, 'shelf':ub.Shelf}
|
||||
for key, db_element in elements.items():
|
||||
tag_names = calibre_db.session.query(db_element).filter(db_element.id.in_(tags['include_' + key])).all()
|
||||
|
@ -267,13 +267,13 @@ def render_adv_search_results(term, offset=None, order=None, limit=None):
|
|||
column_start = term.get('custom_column_' + str(c.id) + '_start')
|
||||
column_end = term.get('custom_column_' + str(c.id) + '_end')
|
||||
if column_start:
|
||||
search_term.extend([u"{} >= {}".format(c.name,
|
||||
search_term.extend(["{} >= {}".format(c.name,
|
||||
format_date(datetime.strptime(column_start, "%Y-%m-%d").date(),
|
||||
format='medium')
|
||||
)])
|
||||
cc_present = True
|
||||
if column_end:
|
||||
search_term.extend([u"{} <= {}".format(c.name,
|
||||
search_term.extend(["{} <= {}".format(c.name,
|
||||
format_date(datetime.strptime(column_end, "%Y-%m-%d").date(),
|
||||
format='medium')
|
||||
)])
|
||||
|
@ -366,7 +366,7 @@ def render_prepare_search_form(cc):
|
|||
.filter(calibre_db.common_filters()) \
|
||||
.group_by(db.Data.format)\
|
||||
.order_by(db.Data.format).all()
|
||||
if current_user.filter_language() == u"all":
|
||||
if current_user.filter_language() == "all":
|
||||
languages = calibre_db.speaking_language()
|
||||
else:
|
||||
languages = None
|
||||
|
|
|
@ -64,7 +64,7 @@ class TaskConvert(CalibreTask):
|
|||
if df:
|
||||
datafile = os.path.join(config.config_calibre_dir,
|
||||
cur_book.path,
|
||||
data.name + u"." + self.settings['old_book_format'].lower())
|
||||
data.name + "." + self.settings['old_book_format'].lower())
|
||||
if not os.path.exists(os.path.join(config.config_calibre_dir, cur_book.path)):
|
||||
os.makedirs(os.path.join(config.config_calibre_dir, cur_book.path))
|
||||
df.GetContentFile(datafile)
|
||||
|
@ -78,7 +78,7 @@ class TaskConvert(CalibreTask):
|
|||
|
||||
filename = self._convert_ebook_format()
|
||||
if config.config_use_google_drive:
|
||||
os.remove(self.file_path + u'.' + self.settings['old_book_format'].lower())
|
||||
os.remove(self.file_path + '.' + self.settings['old_book_format'].lower())
|
||||
|
||||
if filename:
|
||||
if config.config_use_google_drive:
|
||||
|
@ -107,8 +107,8 @@ class TaskConvert(CalibreTask):
|
|||
local_db = db.CalibreDB(expire_on_commit=False, init=True)
|
||||
file_path = self.file_path
|
||||
book_id = self.book_id
|
||||
format_old_ext = u'.' + self.settings['old_book_format'].lower()
|
||||
format_new_ext = u'.' + self.settings['new_book_format'].lower()
|
||||
format_old_ext = '.' + self.settings['old_book_format'].lower()
|
||||
format_new_ext = '.' + self.settings['new_book_format'].lower()
|
||||
|
||||
# check to see if destination format already exists - or if book is in database
|
||||
# if it does - mark the conversion task as complete and return a success
|
||||
|
|
|
@ -166,7 +166,7 @@ class TaskEmail(CalibreTask):
|
|||
self.send_gmail_email(msg)
|
||||
except MemoryError as e:
|
||||
log.error_or_exception(e, stacklevel=3)
|
||||
self._handleError(u'MemoryError sending e-mail: {}'.format(str(e)))
|
||||
self._handleError('MemoryError sending e-mail: {}'.format(str(e)))
|
||||
except (smtplib.SMTPException, smtplib.SMTPAuthenticationError) as e:
|
||||
log.error_or_exception(e, stacklevel=3)
|
||||
if hasattr(e, "smtp_error"):
|
||||
|
@ -177,13 +177,13 @@ class TaskEmail(CalibreTask):
|
|||
text = '\n'.join(e.args)
|
||||
else:
|
||||
text = ''
|
||||
self._handleError(u'Smtplib Error sending e-mail: {}'.format(text))
|
||||
self._handleError('Smtplib Error sending e-mail: {}'.format(text))
|
||||
except (socket.error) as e:
|
||||
log.error_or_exception(e, stacklevel=3)
|
||||
self._handleError(u'Socket Error sending e-mail: {}'.format(e.strerror))
|
||||
self._handleError('Socket Error sending e-mail: {}'.format(e.strerror))
|
||||
except Exception as ex:
|
||||
log.error_or_exception(ex, stacklevel=3)
|
||||
self._handleError(u'Error sending e-mail: {}'.format(ex))
|
||||
self._handleError('Error sending e-mail: {}'.format(ex))
|
||||
|
||||
def send_standard_email(self, msg):
|
||||
use_ssl = int(self.settings.get('mail_use_ssl', 0))
|
||||
|
@ -257,7 +257,7 @@ class TaskEmail(CalibreTask):
|
|||
file_.close()
|
||||
except IOError as e:
|
||||
log.error_or_exception(e, stacklevel=3)
|
||||
log.error(u'The requested file could not be read. Maybe wrong permissions?')
|
||||
log.error('The requested file could not be read. Maybe wrong permissions?')
|
||||
return None
|
||||
return data
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ class TaskGenerateCoverThumbnails(CalibreTask):
|
|||
|
||||
if generated > 0:
|
||||
total_generated += generated
|
||||
self.message = N_(u'Generated %(count)s cover thumbnails', count=total_generated)
|
||||
self.message = N_('Generated %(count)s cover thumbnails', count=total_generated)
|
||||
|
||||
# Check if job has been cancelled or ended
|
||||
if self.stat == STAT_CANCELLED:
|
||||
|
|
|
@ -61,19 +61,19 @@ def render_task_status(tasklist):
|
|||
# localize the task status
|
||||
if isinstance(task.stat, int):
|
||||
if task.stat == STAT_WAITING:
|
||||
ret['status'] = _(u'Waiting')
|
||||
ret['status'] = _('Waiting')
|
||||
elif task.stat == STAT_FAIL:
|
||||
ret['status'] = _(u'Failed')
|
||||
ret['status'] = _('Failed')
|
||||
elif task.stat == STAT_STARTED:
|
||||
ret['status'] = _(u'Started')
|
||||
ret['status'] = _('Started')
|
||||
elif task.stat == STAT_FINISH_SUCCESS:
|
||||
ret['status'] = _(u'Finished')
|
||||
ret['status'] = _('Finished')
|
||||
elif task.stat == STAT_ENDED:
|
||||
ret['status'] = _(u'Ended')
|
||||
ret['status'] = _('Ended')
|
||||
elif task.stat == STAT_CANCELLED:
|
||||
ret['status'] = _(u'Cancelled')
|
||||
ret['status'] = _('Cancelled')
|
||||
else:
|
||||
ret['status'] = _(u'Unknown Status')
|
||||
ret['status'] = _('Unknown Status')
|
||||
|
||||
ret['taskMessage'] = "{}: {}".format(task.name, task.message) if task.message else task.name
|
||||
ret['progress'] = "{} %".format(int(task.progress * 100))
|
||||
|
|
|
@ -492,7 +492,7 @@ class Registration(Base):
|
|||
allow = Column(Integer)
|
||||
|
||||
def __repr__(self):
|
||||
return u"<Registration('{0}')>".format(self.domain)
|
||||
return "<Registration('{0}')>".format(self.domain)
|
||||
|
||||
|
||||
class RemoteAuthToken(Base):
|
||||
|
@ -810,7 +810,7 @@ def create_admin_user(_session):
|
|||
|
||||
def init_db_thread():
|
||||
global app_DB_path
|
||||
engine = create_engine(u'sqlite:///{0}'.format(app_DB_path), echo=False)
|
||||
engine = create_engine('sqlite:///{0}'.format(app_DB_path), echo=False)
|
||||
|
||||
Session = scoped_session(sessionmaker())
|
||||
Session.configure(bind=engine)
|
||||
|
@ -823,7 +823,7 @@ def init_db(app_db_path, user_credentials=None):
|
|||
global app_DB_path
|
||||
|
||||
app_DB_path = app_db_path
|
||||
engine = create_engine(u'sqlite:///{0}'.format(app_db_path), echo=False)
|
||||
engine = create_engine('sqlite:///{0}'.format(app_db_path), echo=False)
|
||||
|
||||
Session = scoped_session(sessionmaker())
|
||||
Session.configure(bind=engine)
|
||||
|
@ -858,7 +858,7 @@ def init_db(app_db_path, user_credentials=None):
|
|||
|
||||
|
||||
def get_new_session_instance():
|
||||
new_engine = create_engine(u'sqlite:///{0}'.format(app_DB_path), echo=False)
|
||||
new_engine = create_engine('sqlite:///{0}'.format(app_DB_path), echo=False)
|
||||
new_session = scoped_session(sessionmaker())
|
||||
new_session.configure(bind=new_engine)
|
||||
|
||||
|
|
|
@ -75,29 +75,29 @@ class Updater(threading.Thread):
|
|||
def do_work(self):
|
||||
try:
|
||||
self.status = 1
|
||||
log.debug(u'Download update file')
|
||||
log.debug('Download update file')
|
||||
headers = {'Accept': 'application/vnd.github.v3+json'}
|
||||
r = requests.get(self._get_request_path(), stream=True, headers=headers, timeout=(10, 600))
|
||||
r.raise_for_status()
|
||||
|
||||
self.status = 2
|
||||
log.debug(u'Opening zipfile')
|
||||
log.debug('Opening zipfile')
|
||||
z = zipfile.ZipFile(BytesIO(r.content))
|
||||
self.status = 3
|
||||
log.debug(u'Extracting zipfile')
|
||||
log.debug('Extracting zipfile')
|
||||
tmp_dir = gettempdir()
|
||||
z.extractall(tmp_dir)
|
||||
folder_name = os.path.join(tmp_dir, z.namelist()[0])[:-1]
|
||||
if not os.path.isdir(folder_name):
|
||||
self.status = 11
|
||||
log.info(u'Extracted contents of zipfile not found in temp folder')
|
||||
log.info('Extracted contents of zipfile not found in temp folder')
|
||||
self.pause()
|
||||
return False
|
||||
self.status = 4
|
||||
log.debug(u'Replacing files')
|
||||
log.debug('Replacing files')
|
||||
if self.update_source(folder_name, constants.BASE_DIR):
|
||||
self.status = 6
|
||||
log.debug(u'Preparing restart of server')
|
||||
log.debug('Preparing restart of server')
|
||||
time.sleep(2)
|
||||
self.web_server.stop(True)
|
||||
self.status = 7
|
||||
|
@ -107,20 +107,20 @@ class Updater(threading.Thread):
|
|||
self.status = 13
|
||||
|
||||
except requests.exceptions.HTTPError as ex:
|
||||
log.error(u'HTTP Error %s', ex)
|
||||
log.error('HTTP Error %s', ex)
|
||||
self.status = 8
|
||||
except requests.exceptions.ConnectionError:
|
||||
log.error(u'Connection error')
|
||||
log.error('Connection error')
|
||||
self.status = 9
|
||||
except requests.exceptions.Timeout:
|
||||
log.error(u'Timeout while establishing connection')
|
||||
log.error('Timeout while establishing connection')
|
||||
self.status = 10
|
||||
except (requests.exceptions.RequestException, zipfile.BadZipFile):
|
||||
self.status = 11
|
||||
log.error(u'General error')
|
||||
log.error('General error')
|
||||
except (IOError, OSError) as ex:
|
||||
self.status = 12
|
||||
log.error(u'Possible Reason for error: update file could not be saved in temp dir')
|
||||
log.error('Possible Reason for error: update file could not be saved in temp dir')
|
||||
log.error_or_exception(ex)
|
||||
self.pause()
|
||||
return False
|
||||
|
@ -386,13 +386,13 @@ class Updater(threading.Thread):
|
|||
r.raise_for_status()
|
||||
update_data = r.json()
|
||||
except requests.exceptions.HTTPError as e:
|
||||
status['message'] = _(u'HTTP Error') + ' ' + str(e)
|
||||
status['message'] = _('HTTP Error') + ' ' + str(e)
|
||||
except requests.exceptions.ConnectionError:
|
||||
status['message'] = _(u'Connection error')
|
||||
status['message'] = _('Connection error')
|
||||
except requests.exceptions.Timeout:
|
||||
status['message'] = _(u'Timeout while establishing connection')
|
||||
status['message'] = _('Timeout while establishing connection')
|
||||
except (requests.exceptions.RequestException, ValueError):
|
||||
status['message'] = _(u'General error')
|
||||
status['message'] = _('General error')
|
||||
return status, update_data
|
||||
|
||||
@staticmethod
|
||||
|
@ -428,18 +428,18 @@ class Updater(threading.Thread):
|
|||
if status['message'] != '':
|
||||
return json.dumps(status)
|
||||
if 'object' not in commit or 'url' not in commit['object']:
|
||||
status['message'] = _(u'Unexpected data while reading update information')
|
||||
status['message'] = _('Unexpected data while reading update information')
|
||||
return json.dumps(status)
|
||||
try:
|
||||
if commit['object']['sha'] == status['current_commit_hash']:
|
||||
status.update({
|
||||
'update': False,
|
||||
'success': True,
|
||||
'message': _(u'No update available. You already have the latest version installed')
|
||||
'message': _('No update available. You already have the latest version installed')
|
||||
})
|
||||
return json.dumps(status)
|
||||
except (TypeError, KeyError):
|
||||
status['message'] = _(u'Unexpected data while reading update information')
|
||||
status['message'] = _('Unexpected data while reading update information')
|
||||
return json.dumps(status)
|
||||
|
||||
# a new update is available
|
||||
|
@ -454,7 +454,7 @@ class Updater(threading.Thread):
|
|||
log.debug("A new update is available.")
|
||||
status['success'] = True
|
||||
status['message'] = _(
|
||||
u'A new update is available. Click on the button below to update to the latest version.')
|
||||
'A new update is available. Click on the button below to update to the latest version.')
|
||||
|
||||
new_commit_date = datetime.datetime.strptime(
|
||||
update_data['committer']['date'], '%Y-%m-%dT%H:%M:%SZ') - tz
|
||||
|
@ -471,7 +471,7 @@ class Updater(threading.Thread):
|
|||
status['history'] = parents[::-1]
|
||||
except (IndexError, KeyError):
|
||||
status['success'] = False
|
||||
status['message'] = _(u'Could not fetch update information')
|
||||
status['message'] = _('Could not fetch update information')
|
||||
log.error("Could not fetch update information")
|
||||
return json.dumps(status)
|
||||
return ''
|
||||
|
@ -482,7 +482,7 @@ class Updater(threading.Thread):
|
|||
'update': True,
|
||||
'success': True,
|
||||
'message': _(
|
||||
u'Click on the button below to update to the latest stable version.'),
|
||||
'Click on the button below to update to the latest stable version.'),
|
||||
'history': parents
|
||||
})
|
||||
self.updateFile = commit[0]['zipball_url']
|
||||
|
@ -490,8 +490,8 @@ class Updater(threading.Thread):
|
|||
status.update({
|
||||
'update': True,
|
||||
'success': True,
|
||||
'message': _(u'A new update is available. Click on the button below to '
|
||||
u'update to version: %(version)s', version=commit[0]['tag_name']),
|
||||
'message': _('A new update is available. Click on the button below to '
|
||||
'update to version: %(version)s', version=commit[0]['tag_name']),
|
||||
'history': parents
|
||||
})
|
||||
self.updateFile = commit[0]['zipball_url']
|
||||
|
|
|
@ -83,7 +83,7 @@ def process(tmp_file_path, original_file_name, original_file_extension, rarExecu
|
|||
|
||||
if meta and meta.title.strip() and meta.author.strip():
|
||||
if meta.author.lower() == 'unknown':
|
||||
meta = meta._replace(author=_(u'Unknown'))
|
||||
meta = meta._replace(author=_('Unknown'))
|
||||
return meta
|
||||
return default_meta(tmp_file_path, original_file_name, original_file_extension)
|
||||
|
||||
|
@ -93,7 +93,7 @@ def default_meta(tmp_file_path, original_file_name, original_file_extension):
|
|||
file_path=tmp_file_path,
|
||||
extension=original_file_extension,
|
||||
title=original_file_name,
|
||||
author=_(u'Unknown'),
|
||||
author=_('Unknown'),
|
||||
cover=None,
|
||||
description="",
|
||||
tags="",
|
||||
|
@ -173,7 +173,7 @@ def pdf_meta(tmp_file_path, original_file_name, original_file_extension):
|
|||
languages = xmp_info['languages']
|
||||
publisher = xmp_info['publisher']
|
||||
else:
|
||||
author = u'Unknown'
|
||||
author = 'Unknown'
|
||||
title = ''
|
||||
languages = [""]
|
||||
publisher = ""
|
||||
|
@ -182,7 +182,7 @@ def pdf_meta(tmp_file_path, original_file_name, original_file_extension):
|
|||
|
||||
if doc_info:
|
||||
if author == '':
|
||||
author = ' & '.join(split_authors([doc_info.author])) if doc_info.author else u'Unknown'
|
||||
author = ' & '.join(split_authors([doc_info.author])) if doc_info.author else 'Unknown'
|
||||
if title == '':
|
||||
title = doc_info.title if doc_info.title else original_file_name
|
||||
if subject == '':
|
||||
|
@ -239,7 +239,7 @@ def get_magick_version():
|
|||
if not use_generic_pdf_cover:
|
||||
ret['Image Magick'] = ImageVersion.MAGICK_VERSION
|
||||
else:
|
||||
ret['Image Magick'] = u'not installed'
|
||||
ret['Image Magick'] = 'not installed'
|
||||
return ret
|
||||
|
||||
|
||||
|
|
10
cps/web.py
10
cps/web.py
|
@ -739,10 +739,10 @@ def render_read_books(page, are_read, as_xml=False, order=None):
|
|||
return entries, pagination
|
||||
else:
|
||||
if are_read:
|
||||
name = _(u'Read Books') + ' (' + str(pagination.total_count) + ')'
|
||||
name = _('Read Books') + ' (' + str(pagination.total_count) + ')'
|
||||
page_name = "read"
|
||||
else:
|
||||
name = _(u'Unread Books') + ' (' + str(pagination.total_count) + ')'
|
||||
name = _('Unread Books') + ' (' + str(pagination.total_count) + ')'
|
||||
page_name = "unread"
|
||||
return render_title_template('index.html', random=random, entries=entries, pagination=pagination,
|
||||
title=name, page=page_name, order=order[1])
|
||||
|
@ -765,7 +765,7 @@ def render_archived_books(page, sort_param):
|
|||
True,
|
||||
True, config.config_read_column)
|
||||
|
||||
name = _(u'Archived Books') + ' (' + str(len(archived_book_ids)) + ')'
|
||||
name = _('Archived Books') + ' (' + str(len(archived_book_ids)) + ')'
|
||||
page_name = "archived"
|
||||
return render_title_template('index.html', random=random, entries=entries, pagination=pagination,
|
||||
title=name, page=page_name, order=sort_param[1])
|
||||
|
@ -917,7 +917,7 @@ def author_list():
|
|||
for entry in author_copy:
|
||||
entry.Authors.name = entry.Authors.name.replace('|', ',')
|
||||
return render_title_template('list.html', entries=author_copy, folder='web.books_list', charlist=char_list,
|
||||
title=u"Authors", page="authorlist", data='author', order=order_no)
|
||||
title="Authors", page="authorlist", data='author', order=order_no)
|
||||
else:
|
||||
abort(404)
|
||||
|
||||
|
@ -1066,7 +1066,7 @@ def formats_list():
|
|||
@web.route("/language")
|
||||
@login_required_if_no_ano
|
||||
def language_overview():
|
||||
if current_user.check_visibility(constants.SIDEBAR_LANGUAGE) and current_user.filter_language() == u"all":
|
||||
if current_user.check_visibility(constants.SIDEBAR_LANGUAGE) and current_user.filter_language() == "all":
|
||||
order_no = 0 if current_user.get_view_property('language', 'dir') == 'desc' else 1
|
||||
languages = calibre_db.speaking_language(reverse_order=not order_no, with_count=True)
|
||||
char_list = generate_char_list(languages)
|
||||
|
|
Loading…
Reference in New Issue
Block a user