mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
convert some legacy percent format (manual)
ruff 'UP031'
This commit is contained in:
parent
0560b429bf
commit
047ebcffe4
@ -50,7 +50,7 @@ class EPUBHelpBuilder(EpubBuilder):
|
||||
fmt, width, height = identify(container.raw_data(imgname))
|
||||
if width == -1:
|
||||
raise ValueError('Failed to read size of: {}'.format(imgname))
|
||||
img.set('style', 'width: %dpx; height: %dpx' % (width, height))
|
||||
img.set('style', 'width: {}px; height: {}px'.format(width, height))
|
||||
|
||||
def fix_opf(self, container):
|
||||
spine_names = {n for n, l in container.spine_names}
|
||||
|
@ -21,7 +21,7 @@ from setup import SRC, Command, isbsd, isfreebsd, ishaiku, islinux, ismacos, isw
|
||||
|
||||
isunix = islinux or ismacos or isbsd or ishaiku
|
||||
|
||||
py_lib = os.path.join(sys.prefix, 'libs', 'python%d%d.lib' % sys.version_info[:2])
|
||||
py_lib = os.path.join(sys.prefix, 'libs', 'python{}{}.lib'.format(*sys.version_info[:2]))
|
||||
|
||||
class CompileCommand(NamedTuple):
|
||||
cmd: list[str]
|
||||
@ -657,7 +657,7 @@ class Build(Command):
|
||||
os.chdir(bdir)
|
||||
try:
|
||||
self.check_call(cmd + ['-S', os.path.dirname(sources[0])])
|
||||
self.check_call([self.env.make] + ['-j%d'%(cpu_count or 1)])
|
||||
self.check_call([self.env.make] + ['-j{}'.format(cpu_count or 1)])
|
||||
finally:
|
||||
os.chdir(cwd)
|
||||
os.rename(self.j(bdir, 'libheadless.so'), target)
|
||||
@ -734,7 +734,7 @@ sip-file = {os.path.basename(sipf)!r}
|
||||
env = os.environ.copy()
|
||||
if is_macos_universal_build:
|
||||
env['ARCHS'] = 'x86_64 arm64'
|
||||
self.check_call([self.env.make] + ([] if iswindows else ['-j%d'%(os.cpu_count() or 1)]), env=env)
|
||||
self.check_call([self.env.make] + ([] if iswindows else ['-j{}'.format(os.cpu_count() or 1)]), env=env)
|
||||
e = 'pyd' if iswindows else 'so'
|
||||
m = glob.glob(f'{ext.name}/{ext.name}.*{e}')
|
||||
if not m:
|
||||
|
@ -150,7 +150,7 @@ class Check(Command):
|
||||
for i, f in enumerate(dirty_files):
|
||||
self.info('\tChecking', f)
|
||||
if self.file_has_errors(f):
|
||||
self.info('%d files left to check' % (len(dirty_files) - i - 1))
|
||||
self.info('{} files left to check'.format(len(dirty_files) - i - 1))
|
||||
try:
|
||||
edit_file(f)
|
||||
except FileNotFoundError:
|
||||
|
@ -56,16 +56,16 @@ class ReadFileWithProgressReporting: # {{{
|
||||
eta = int((self._total - self.tell()) / bit_rate) + 1
|
||||
eta_m, eta_s = eta / 60, eta % 60
|
||||
sys.stdout.write(
|
||||
' %.1f%% %.1f/%.1fMB %.1f KB/sec %d minutes, %d seconds left' %
|
||||
(frac * 100, mb_pos, mb_tot, kb_rate, eta_m, eta_s)
|
||||
' {:.1f}% {:.1f}/{:.1f}MB {:.1f} KB/sec {} minutes, {} seconds left'
|
||||
.format(frac * 100, mb_pos, mb_tot, kb_rate, eta_m, eta_s)
|
||||
)
|
||||
sys.stdout.write('\x1b[u')
|
||||
if self.tell() >= self._total:
|
||||
sys.stdout.write('\n')
|
||||
t = int(time.time() - self.start_time) + 1
|
||||
print(
|
||||
'Upload took %d minutes and %d seconds at %.1f KB/sec' %
|
||||
(t / 60, t % 60, kb_rate)
|
||||
'Upload took {} minutes and {} seconds at {:.1f} KB/sec'
|
||||
.format(t/60, t % 60, kb_rate)
|
||||
)
|
||||
sys.stdout.flush()
|
||||
|
||||
|
@ -388,7 +388,7 @@ class Bootstrap(Command):
|
||||
st = time.time()
|
||||
clone_cmd.insert(2, '--depth=1')
|
||||
subprocess.check_call(clone_cmd, cwd=self.d(self.SRC))
|
||||
print('Downloaded translations in %d seconds' % int(time.time() - st))
|
||||
print('Downloaded translations in {} seconds'.format(int(time.time() - st)))
|
||||
else:
|
||||
if os.path.exists(tdir):
|
||||
subprocess.check_call(['git', 'pull'], cwd=tdir)
|
||||
|
@ -20,7 +20,7 @@ def generate_data():
|
||||
ans = []
|
||||
for x, limit in (('day', 8), ('mon', 13)):
|
||||
for attr in ('ab' + x, x):
|
||||
ans.append((attr, tuple(map(nl, (getattr(locale, '%s_%d' % (attr.upper(), i)) for i in range(1, limit)))))),
|
||||
ans.append((attr, tuple(map(nl, (getattr(locale, '{}_{}'.format(attr.upper(), i)) for i in range(1, limit)))))),
|
||||
for x in ('d_t_fmt', 'd_fmt', 't_fmt', 't_fmt_ampm', 'radixchar', 'thousep', 'yesexpr', 'noexpr'):
|
||||
ans.append((x, nl(getattr(locale, x.upper()))))
|
||||
return ans
|
||||
|
@ -476,7 +476,7 @@ def plugin_to_index(plugin, count):
|
||||
block.append('<br>')
|
||||
block.append('<li>{}</li>'.format(li))
|
||||
block = '<ul>{}</ul>'.format('\n'.join(block))
|
||||
downloads = ('\xa0<span class="download-count">[%d total downloads]</span>' % count) if count else ''
|
||||
downloads = ('\xa0<span class="download-count">[{} total downloads]</span>'.format(count)) if count else ''
|
||||
zipfile = '<div class="end"><a href={} title="Download plugin" download={}>Download plugin \u2193</a>{}</div>'.format(
|
||||
quoteattr(plugin['file']), quoteattr(plugin['name'] + '.zip'), downloads)
|
||||
desc = plugin['description'] or ''
|
||||
|
@ -203,7 +203,7 @@ class Manual(Command):
|
||||
sys.executable, self.j(self.d(self.SRC), 'manual', 'build.py'),
|
||||
language, self.j(tdir, language)
|
||||
], '\n\n**************** Building translations for: {}'.format(language)))
|
||||
self.info('Building manual for %d languages' % len(jobs))
|
||||
self.info('Building manual for {} languages'.format(len(jobs)))
|
||||
subprocess.check_call(jobs[0].cmd)
|
||||
if not parallel_build(jobs[1:], self.info):
|
||||
raise SystemExit(1)
|
||||
@ -222,8 +222,8 @@ class Manual(Command):
|
||||
if x and not os.path.exists(x):
|
||||
os.symlink('.', x)
|
||||
self.info(
|
||||
'Built manual for %d languages in %s minutes' %
|
||||
(len(jobs), int((time.time() - st) / 60.))
|
||||
'Built manual for {} languages in {} minutes'
|
||||
.format(len(jobs), int((time.time() - st) / 60.))
|
||||
)
|
||||
finally:
|
||||
os.chdir(cwd)
|
||||
|
@ -37,7 +37,7 @@ class Test(BaseTest):
|
||||
super().add_options(parser)
|
||||
parser.add_option('--test-verbosity', type=int, default=4, help='Test verbosity (0-4)')
|
||||
parser.add_option('--test-module', '--test-group', default=[], action='append', type='choice', choices=sorted(map(str, TEST_MODULES)),
|
||||
help='The test module to run (can be specified more than once for multiple modules). Choices: {}'.format(', '.join(sorted(TEST_MODULES))))
|
||||
help='The test module to run (can be specified more than once for multiple modules). Choices: {}'.format(', '.join(sorted(TEST_MODULES))))
|
||||
parser.add_option('--test-name', '-n', default=[], action='append',
|
||||
help='The name of an individual test to run. Can be specified more than once for multiple tests. The name of the'
|
||||
' test is the name of the test function without the leading test_. For example, the function test_something()'
|
||||
|
@ -93,7 +93,7 @@ class POT(Command): # {{{
|
||||
|
||||
ans = []
|
||||
for lineno, msg in msgs:
|
||||
ans.append('#: %s:%d'%(path, lineno))
|
||||
ans.append('#: {}:{}'.format(path, lineno))
|
||||
slash = codepoint_to_chr(92)
|
||||
msg = msg.replace(slash, slash*2).replace('"', r'\"').replace('\n',
|
||||
r'\n').replace('\r', r'\r').replace('\t', r'\t')
|
||||
|
@ -275,7 +275,7 @@ def cnv_points(attribute, arg, element):
|
||||
return arg
|
||||
else:
|
||||
try:
|
||||
strarg = ' '.join(['%d,%d' % p for p in arg])
|
||||
strarg = ' '.join(['{},{}'.format(*p) for p in arg])
|
||||
except:
|
||||
raise ValueError('Points must be string or [(0,0),(1,1)] - not {}'.format(arg))
|
||||
return strarg
|
||||
|
@ -131,7 +131,7 @@ class ParagraphProps:
|
||||
|
||||
def __unicode__(self):
|
||||
|
||||
return '[bq=%s, h=%d, code=%s]' % (unicode_type(self.blockquote),
|
||||
return '[bq={}, h={}, code={}]'.format(unicode_type(self.blockquote),
|
||||
self.headingLevel,
|
||||
unicode_type(self.code))
|
||||
__str__ = __unicode__
|
||||
|
@ -647,7 +647,7 @@ class ODF2XHTML(handler.ContentHandler):
|
||||
''' Create a unique anchor id for a href name '''
|
||||
if name not in self.anchors:
|
||||
# Changed by Kovid
|
||||
self.anchors[name] = 'anchor%d' % (len(self.anchors) + 1)
|
||||
self.anchors[name] = 'anchor{}'.format(len(self.anchors) + 1)
|
||||
return self.anchors.get(name)
|
||||
|
||||
def purgedata(self):
|
||||
@ -940,13 +940,13 @@ dl.notes dd:last-of-type { page-break-after: avoid }
|
||||
for key in range(1,self.currentnote+1):
|
||||
note = self.notedict[key]
|
||||
# for key,note in self.notedict.items():
|
||||
self.opentag('dt', {'id':'footnote-%d' % key})
|
||||
self.opentag('dt', {'id':'footnote-{}'.format(key)})
|
||||
# self.opentag('sup')
|
||||
# self.writeout(escape(note['citation']))
|
||||
# self.closetag('sup', False)
|
||||
self.writeout('[')
|
||||
self.opentag('a', {'href': '#citation-%d' % key})
|
||||
self.writeout('←%d' % key)
|
||||
self.opentag('a', {'href': '#citation-{}'.format(key)})
|
||||
self.writeout('←{}'.format(key))
|
||||
self.closetag('a')
|
||||
self.writeout(']\xa0')
|
||||
self.closetag('dt')
|
||||
@ -1335,7 +1335,7 @@ dl.notes dd:last-of-type { page-break-after: avoid }
|
||||
# the list level must return to 1, even though the table or
|
||||
# textbox itself may be nested within another list.
|
||||
name = self.tagstack.rfindattr((TEXTNS,'style-name'))
|
||||
list_class = '%s_%d' % (name, level)
|
||||
list_class = '{}_{}'.format(name, level)
|
||||
tag_name = self.listtypes.get(list_class,'ul')
|
||||
number_class = tag_name + list_class
|
||||
if list_id:
|
||||
@ -1372,7 +1372,7 @@ dl.notes dd:last-of-type { page-break-after: avoid }
|
||||
# the list level must return to 1, even though the table or
|
||||
# textbox itself may be nested within another list.
|
||||
name = self.tagstack.rfindattr((TEXTNS,'style-name'))
|
||||
list_class = '%s_%d' % (name, level)
|
||||
list_class = '{}_{}'.format(name, level)
|
||||
self.closetag(self.listtypes.get(list_class,'ul'))
|
||||
self.purgedata()
|
||||
|
||||
|
@ -114,4 +114,4 @@ if __name__ == '__main__':
|
||||
import sys
|
||||
result = odfmanifest(sys.argv[1])
|
||||
for file in result.values():
|
||||
print('%-40s %-40s' % (file['media-type'], file['full-path']))
|
||||
print('{:<40} {:<40}'.format(file['media-type'], file['full-path']))
|
||||
|
@ -385,7 +385,7 @@ class OpenDocument:
|
||||
'''
|
||||
self.childobjects.append(document)
|
||||
if objectname is None:
|
||||
document.folder = '%s/Object %d' % (self.folder, len(self.childobjects))
|
||||
document.folder = '{}/Object {}'.format(self.folder, len(self.childobjects))
|
||||
else:
|
||||
document.folder = objectname
|
||||
return '.{}'.format(document.folder)
|
||||
@ -407,7 +407,7 @@ class OpenDocument:
|
||||
# Look in subobjects
|
||||
subobjectnum = 1
|
||||
for subobject in object.childobjects:
|
||||
self._savePictures(subobject,'%sObject %d/' % (folder, subobjectnum))
|
||||
self._savePictures(subobject,'{}Object {}/'.format(folder, subobjectnum))
|
||||
subobjectnum += 1
|
||||
|
||||
def __replaceGenerator(self):
|
||||
@ -524,7 +524,7 @@ class OpenDocument:
|
||||
# Write subobjects
|
||||
subobjectnum = 1
|
||||
for subobject in object.childobjects:
|
||||
self._saveXmlObjects(subobject, '%sObject %d/' % (folder, subobjectnum))
|
||||
self._saveXmlObjects(subobject, '{}Object {}/'.format(folder, subobjectnum))
|
||||
subobjectnum += 1
|
||||
|
||||
# Document's DOM methods
|
||||
|
Loading…
x
Reference in New Issue
Block a user