convert some legacy percent format (extra-edit)

This commit is contained in:
un-pogaz 2025-01-24 11:14:16 +01:00
parent 047ebcffe4
commit 02854d8b8c
11 changed files with 41 additions and 41 deletions

View File

@ -42,7 +42,7 @@ def merge():
recover=True, no_network=True, resolve_entities=False recover=True, no_network=True, resolve_entities=False
) )
) )
symbol = ans.makeelement('{{{}}}symbol'.format(SVG_NS)) symbol = ans.makeelement('{%s}symbol' % SVG_NS) # noqa: UP031
symbol.set('viewBox', svg.get('viewBox')) symbol.set('viewBox', svg.get('viewBox'))
symbol.set('id', 'icon-' + f.rpartition('.')[0]) symbol.set('id', 'icon-' + f.rpartition('.')[0])
for child in svg.iterchildren('*'): for child in svg.iterchildren('*'):

View File

@ -253,5 +253,5 @@ latex_show_pagerefs = True
latex_show_urls = 'footnote' latex_show_urls = 'footnote'
latex_elements = { latex_elements = {
'papersize':'letterpaper', 'papersize':'letterpaper',
'preamble': r'\renewcommand{{\pageautorefname}}{{{}}}'.format(_('page')), 'preamble': r'\renewcommand{\pageautorefname}{%s}' % _('page'), # noqa: UP031
} }

View File

@ -136,7 +136,7 @@ class Liberation(BasicNewsRecipe):
b64 = base64.b64decode(self.key) b64 = base64.b64decode(self.key)
query = { query = {
'website': 'liberation', 'website': 'liberation',
'website_url': '{}'.format(slug), 'website_url': str(slug),
'published': 'true', 'published': 'true',
'_sourceInclude': '_id,content_restrictions.content_code,credits,promo_items.basic.caption,promo_items.basic.credits,promo_items.basic.url,promo_items.basic.height,promo_items.basic.width,promo_items.basic.resized_image_urls,promo_items.basic.last_updated_date,promo_items.lead_art.caption,promo_items.lead_art.credits,promo_items.lead_art.url,promo_items.lead_art.height,promo_items.lead_art.width,promo_items.lead_art.resized_image_urls,promo_items.lead_art.last_updated_date,source.additional_properties.legacy_url,content_elements,source.source_id,taxonomy.primary_section.additional_properties.original._admin.alias_ids,taxonomy.primary_section.additional_properties.original.navigation.nav_title,taxonomy.primary_section._id,taxonomy.primary_section.name,taxonomy.primary_section.path,taxonomy.tags,label,subheadlines.basic,headlines.basic,source.additional_properties.legacy_url,source.source_type,first_publish_date,display_date,canonical_url' # noqa: E501 '_sourceInclude': '_id,content_restrictions.content_code,credits,promo_items.basic.caption,promo_items.basic.credits,promo_items.basic.url,promo_items.basic.height,promo_items.basic.width,promo_items.basic.resized_image_urls,promo_items.basic.last_updated_date,promo_items.lead_art.caption,promo_items.lead_art.credits,promo_items.lead_art.url,promo_items.lead_art.height,promo_items.lead_art.width,promo_items.lead_art.resized_image_urls,promo_items.lead_art.last_updated_date,source.additional_properties.legacy_url,content_elements,source.source_id,taxonomy.primary_section.additional_properties.original._admin.alias_ids,taxonomy.primary_section.additional_properties.original.navigation.nav_title,taxonomy.primary_section._id,taxonomy.primary_section.name,taxonomy.primary_section.path,taxonomy.tags,label,subheadlines.basic,headlines.basic,source.additional_properties.legacy_url,source.source_type,first_publish_date,display_date,canonical_url' # noqa: E501
} }

View File

@ -126,7 +126,7 @@ def initialize_constants():
with open(os.path.join(SRC, 'calibre/constants.py'), 'rb') as f: with open(os.path.join(SRC, 'calibre/constants.py'), 'rb') as f:
src = f.read().decode('utf-8') src = f.read().decode('utf-8')
nv = re.search(r'numeric_version\s+=\s+\((\d+), (\d+), (\d+)\)', src) nv = re.search(r'numeric_version\s+=\s+\((\d+), (\d+), (\d+)\)', src)
__version__ = '{}.{}.{}'.format(nv.group(1), nv.group(2), nv.group(3)) __version__ = '.'.join([nv.group(1), nv.group(2), nv.group(3)])
__appname__ = re.search(r'__appname__\s+=\s+(u{0,1})[\'"]([^\'"]+)[\'"]', __appname__ = re.search(r'__appname__\s+=\s+(u{0,1})[\'"]([^\'"]+)[\'"]',
src).group(2) src).group(2)
with open(os.path.join(SRC, 'calibre/linux.py'), 'rb') as sf: with open(os.path.join(SRC, 'calibre/linux.py'), 'rb') as sf:

View File

@ -23,8 +23,8 @@ message with the summary of the closed bug.
LAUNCHPAD = os.path.expanduser('~/work/env/launchpad.py') LAUNCHPAD = os.path.expanduser('~/work/env/launchpad.py')
LAUNCHPAD_BUG = 'https://bugs.launchpad.net/calibre/+bug/%s' LAUNCHPAD_BUG = 'https://bugs.launchpad.net/calibre/+bug/{}'
GITHUB_BUG = 'https://api.github.com/repos/kovidgoyal/calibre/issues/%s' GITHUB_BUG = 'https://api.github.com/repos/kovidgoyal/calibre/issues/{}'
BUG_PAT = r'(Fix|Implement|Fixes|Fixed|Implemented|See)\s+#(\d+)' BUG_PAT = r'(Fix|Implement|Fixes|Fixed|Implemented|See)\s+#(\d+)'
socket.setdefaulttimeout(90) socket.setdefaulttimeout(90)
@ -44,18 +44,18 @@ class Bug:
if int(bug) > 100000: # Launchpad bug if int(bug) > 100000: # Launchpad bug
try: try:
raw = urllib.request.urlopen(LAUNCHPAD_BUG % bug).read() raw = urllib.request.urlopen(LAUNCHPAD_BUG.format(bug)).read()
h1 = html.fromstring(raw).xpath('//h1[@id="edit-title"]')[0] h1 = html.fromstring(raw).xpath('//h1[@id="edit-title"]')[0]
summary = html.tostring(h1, method='text', encoding=str).strip() summary = html.tostring(h1, method='text', encoding=str).strip()
except: except:
summary = 'Private bug' summary = 'Private bug'
else: else:
summary = json.loads(urllib.request.urlopen(GITHUB_BUG % bug).read())['title'] summary = json.loads(urllib.request.urlopen(GITHUB_BUG.format(bug)).read())['title']
if summary: if summary:
print('Working on bug:', summary) print('Working on bug:', summary)
if int(bug) > 100000 and action != 'See': if int(bug) > 100000 and action != 'See':
self.close_bug(bug, action) self.close_bug(bug, action)
return match.group() + f' [{summary}]({LAUNCHPAD_BUG % bug})' return match.group() + f' [{summary}]({LAUNCHPAD_BUG.format(bug)})'
return match.group() + ' ({})'.format(summary) return match.group() + ' ({})'.format(summary)
return match.group() return match.group()

View File

@ -416,20 +416,20 @@ def upload_to_servers(files, version): # {{{
# for server, rdir in {'files':'/srv/download/'}.items(): # for server, rdir in {'files':'/srv/download/'}.items():
# print('Uploading to server:', server) # print('Uploading to server:', server)
# server = '%s.calibre-ebook.com' % server # server = f'{server}.calibre-ebook.com'
# # Copy the generated index files # # Copy the generated index files
# print('Copying generated index') # print('Copying generated index')
# check_call(['rsync', '-hza', '-e', 'ssh -x', '--include', '*.html', # check_call(['rsync', '-hza', '-e', 'ssh -x', '--include', '*.html',
# '--filter', '-! */', base, 'root@%s:%s' % (server, rdir)]) # '--filter', '-! */', base, f'root@{server}:{rdir}'])
# # Copy the release files # # Copy the release files
# rdir = '%s%s/' % (rdir, version) # rdir = f'{rdir}{version}/'
# for x in files: # for x in files:
# start = time.time() # start = time.time()
# print('Uploading', x) # print('Uploading', x)
# for i in range(5): # for i in range(5):
# try: # try:
# check_call(['rsync', '-h', '-z', '--progress', '-e', 'ssh -x', x, # check_call(['rsync', '-h', '-z', '--progress', '-e', 'ssh -x', x,
# 'root@%s:%s'%(server, rdir)]) # f'root@{server}:{rdir}'])
# except KeyboardInterrupt: # except KeyboardInterrupt:
# raise SystemExit(1) # raise SystemExit(1)
# except: # except:

View File

@ -502,25 +502,25 @@ def create_index(index, raw_stats):
<head><meta charset="utf-8"><title>Index of calibre plugins</title> <head><meta charset="utf-8"><title>Index of calibre plugins</title>
<link rel="icon" type="image/x-icon" href="//calibre-ebook.com/favicon.ico" /> <link rel="icon" type="image/x-icon" href="//calibre-ebook.com/favicon.ico" />
<style type="text/css"> <style type="text/css">
body {{ background-color: #eee; }} body { background-color: #eee; }
a {{ text-decoration: none }} a { text-decoration: none }
a:hover, h3:hover {{ color: red }} a:hover, h3:hover { color: red }
a:visited {{ color: blue }} a:visited { color: blue }
ul {{ list-style-type: none; font-size: smaller }} ul { list-style-type: none; font-size: smaller }
li {{ display: inline }} li { display: inline }
li+li:before {{ content: " - " }} li+li:before { content: " - " }
.end {{ border-bottom: solid 1pt black; padding-bottom: 0.5ex; margin-bottom: 4ex; }} .end { border-bottom: solid 1pt black; padding-bottom: 0.5ex; margin-bottom: 4ex; }
h1 img, h3 img {{ vertical-align: middle; margin-right: 0.5em; }} h1 img, h3 img { vertical-align: middle; margin-right: 0.5em; }
h1 {{ text-align: center }} h1 { text-align: center }
.download-count {{ color: gray; font-size: smaller }} .download-count { color: gray; font-size: smaller }
</style> </style>
</head> </head>
<body> <body>
<h1><img src="//manual.calibre-ebook.com/_static/logo.png">Index of calibre plugins</h1> <h1><img src="//manual.calibre-ebook.com/_static/logo.png">Index of calibre plugins</h1>
<div style="text-align:center"><a href="stats.html">Download counts for all plugins</a></div> <div style="text-align:center"><a href="stats.html">Download counts for all plugins</a></div>
{} %s
</body> </body>
</html>'''.format('\n'.join(plugins)) </html>''' % ('\n'.join(plugins)) # noqa: UP031
raw = index.encode('utf-8') raw = index.encode('utf-8')
try: try:
with open('index.html', 'rb') as f: with open('index.html', 'rb') as f:
@ -541,20 +541,20 @@ h1 {{ text-align: center }}
<head><meta charset="utf-8"><title>Stats for calibre plugins</title> <head><meta charset="utf-8"><title>Stats for calibre plugins</title>
<link rel="icon" type="image/x-icon" href="//calibre-ebook.com/favicon.ico" /> <link rel="icon" type="image/x-icon" href="//calibre-ebook.com/favicon.ico" />
<style type="text/css"> <style type="text/css">
body {{ background-color: #eee; }} body { background-color: #eee; }
h1 img, h3 img {{ vertical-align: middle; margin-right: 0.5em; }} h1 img, h3 img { vertical-align: middle; margin-right: 0.5em; }
h1 {{ text-align: center }} h1 { text-align: center }
</style> </style>
</head> </head>
<body> <body>
<h1><img src="//manual.calibre-ebook.com/_static/logo.png">Stats for calibre plugins</h1> <h1><img src="//manual.calibre-ebook.com/_static/logo.png">Stats for calibre plugins</h1>
<table> <table>
<tr><th>Plugin</th><th>Total downloads</th></tr> <tr><th>Plugin</th><th>Total downloads</th></tr>
{} %s
</table> </table>
</body> </body>
</html> </html>
'''.format('\n'.join(pstats)) ''' % ('\n'.join(pstats)) # noqa: UP031
raw = stats.encode('utf-8') raw = stats.encode('utf-8')
try: try:
with open('stats.html', 'rb') as f: with open('stats.html', 'rb') as f:

View File

@ -171,14 +171,14 @@ class POT(Command): # {{{
def pot_header(self, appname=__appname__, version=__version__): def pot_header(self, appname=__appname__, version=__version__):
return textwrap.dedent('''\ return textwrap.dedent('''\
# Translation template file.. # Translation template file..
# Copyright (C) %(year)s Kovid Goyal # Copyright (C) {year} Kovid Goyal
# Kovid Goyal <kovid@kovidgoyal.net>, %(year)s. # Kovid Goyal <kovid@kovidgoyal.net>, {year}.
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: %(appname)s %(version)s\\n" "Project-Id-Version: {appname} {version}\\n"
"POT-Creation-Date: %(time)s\\n" "POT-Creation-Date: {time}\\n"
"PO-Revision-Date: %(time)s\\n" "PO-Revision-Date: {time}\\n"
"Last-Translator: Automatically generated\\n" "Last-Translator: Automatically generated\\n"
"Language-Team: LANGUAGE\\n" "Language-Team: LANGUAGE\\n"
"MIME-Version: 1.0\\n" "MIME-Version: 1.0\\n"
@ -187,7 +187,7 @@ class POT(Command): # {{{
"Content-Type: text/plain; charset=UTF-8\\n" "Content-Type: text/plain; charset=UTF-8\\n"
"Content-Transfer-Encoding: 8bit\\n" "Content-Transfer-Encoding: 8bit\\n"
''')%dict(appname=appname, version=version, ''').format(appname=appname, version=version,
year=time.strftime('%Y'), year=time.strftime('%Y'),
time=time.strftime('%Y-%m-%d %H:%M+%Z')) time=time.strftime('%Y-%m-%d %H:%M+%Z'))

View File

@ -126,7 +126,7 @@ def __save_prefix(attribute, arg, element):
return str(arg) return str(arg)
namespace = element.get_knownns(prefix) namespace = element.get_knownns(prefix)
if namespace is None: if namespace is None:
# raise ValueError("'%s' is an unknown prefix" % unicode_type(prefix)) # raise ValueError(f"'{unicode_type(prefix)}' is an unknown prefix")
return str(arg) return str(arg)
return str(arg) return str(arg)

View File

@ -662,7 +662,7 @@ class ODF2XHTML(handler.ContentHandler):
''' Get the title from the meta data and create a HTML <title> ''' Get the title from the meta data and create a HTML <title>
''' '''
self.title = ''.join(self.data) self.title = ''.join(self.data)
# self.metatags.append('<title>%s</title>\n' % escape(self.title)) # self.metatags.append('<title>{}</title>\n'.format(escape(self.title)))
self.data = [] self.data = []
def e_dc_metatag(self, tag, attrs): def e_dc_metatag(self, tag, attrs):
@ -1355,7 +1355,7 @@ dl.notes dd:last-of-type { page-break-after: avoid }
attrs = {'start': unicode_type(self.list_number_map[number_class])} attrs = {'start': unicode_type(self.list_number_map[number_class])}
if self.generate_css: if self.generate_css:
attrs['class'] = list_class attrs['class'] = list_class
self.opentag('{}'.format(tag_name), attrs) self.opentag(str(tag_name), attrs)
self.purgedata() self.purgedata()
def e_text_list(self, tag, attrs): def e_text_list(self, tag, attrs):

View File

@ -403,7 +403,7 @@ class OpenDocument:
self._z.writestr(zi, fileobj) self._z.writestr(zi, fileobj)
# According to section 17.7.3 in ODF 1.1, the pictures folder should not have a manifest entry # According to section 17.7.3 in ODF 1.1, the pictures folder should not have a manifest entry
# if hasPictures: # if hasPictures:
# self.manifest.addElement(manifest.FileEntry(fullpath="%sPictures/" % folder, mediatype="")) # self.manifest.addElement(manifest.FileEntry(fullpath=f"{folder}Pictures/", mediatype=""))
# Look in subobjects # Look in subobjects
subobjectnum = 1 subobjectnum = 1
for subobject in object.childobjects: for subobject in object.childobjects: