Cleanup previous PR

This commit is contained in:
Kovid Goyal 2025-01-25 17:31:21 +05:30
parent 7e61ea2248
commit c10832387d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
13 changed files with 18 additions and 18 deletions

View File

@ -143,7 +143,7 @@ class WSJ(BasicNewsRecipe):
br.addheaders += [
('Accept-Encoding', 'gzip'),
('cache-control', 'no-cache'),
('x-api-key', ('eb2408cd27f8913d421fa3d5c3d07ccf034cb448')),
('x-api-key', ('e''b''2''4''0''8''c''d''2''7''f''8''9''1''3''d''4''2''1''f''a''3''d''5''c''3''d''0''7''c''c''f''0''3''4''c''b''4''4''8')),
]
return br

View File

@ -118,7 +118,7 @@ class WSJ(BasicNewsRecipe):
br.addheaders += [
('Accept-Encoding', 'gzip'),
('cache-control', 'no-cache'),
('x-api-key', ('eb2408cd27f8913d421fa3d5c3d07ccf034cb448')),
('x-api-key', ('e''b''2''4''0''8''c''d''2''7''f''8''9''1''3''d''4''2''1''f''a''3''d''5''c''3''d''0''7''c''c''f''0''3''4''c''b''4''4''8')),
]
return br

View File

@ -151,7 +151,7 @@ class WSJ(BasicNewsRecipe):
br.addheaders += [
('Accept-Encoding', 'gzip'),
('cache-control', 'no-cache'),
('x-api-key', ('eb2408cd27f8913d421fa3d5c3d07ccf034cb448')),
('x-api-key', ('e''b''2''4''0''8''c''d''2''7''f''8''9''1''3''d''4''2''1''f''a''3''d''5''c''3''d''0''7''c''c''f''0''3''4''c''b''4''4''8')),
]
return br

View File

@ -126,7 +126,7 @@ def initialize_constants():
with open(os.path.join(SRC, 'calibre/constants.py'), 'rb') as f:
src = f.read().decode('utf-8')
nv = re.search(r'numeric_version\s+=\s+\((\d+), (\d+), (\d+)\)', src)
__version__ = '.'.join([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})[\'"]([^\'"]+)[\'"]',
src).group(2)
with open(os.path.join(SRC, 'calibre/linux.py'), 'rb') as sf:

View File

@ -13,7 +13,7 @@ def parse(raw, parse_dates=True):
nonlocal current_entry, current_section
if not stripped_line:
return normal
if stripped_line.startswith('{{{'):
if stripped_line.startswith('{' '{' '{'):
parts = line.split()[1:]
if len(parts) != 2:
raise ValueError(f'The entry start line is malformed: {line}')
@ -31,7 +31,7 @@ def parse(raw, parse_dates=True):
def in_entry(linenum, line, stripped_line):
nonlocal current_section, current_entry
if stripped_line == '}}}':
if stripped_line == '}' '}' '}':
if current_entry is None:
raise ValueError(f'Entry terminator without active entry at line: {linenum}')
entries.append(current_entry)
@ -93,7 +93,7 @@ def parse(raw, parse_dates=True):
if line.startswith('-'):
finalize_item(item)
return start_item(linenum, line, stripped_line)
if line.startswith('}}}'):
if line.startswith('}' '}' '}'):
return in_entry(linenum, line, stripped_line)
if not stripped_line:
if 'description' not in item:
@ -138,7 +138,7 @@ def migrate():
lines = []
for entry in entries:
lines.append('')
lines.append('{{{'+f' {entry["version"]} {entry["date"]}')
lines.append('{' '{' '{'+f' {entry["version"]} {entry["date"]}')
for w in ('new features', 'bug fixes'):
nf = entry.get(w)
if nf:
@ -166,7 +166,7 @@ def migrate():
lines.append('')
with open(name.replace('yaml', 'txt'), 'w') as f:
f.write('\n'.join(lines))
lines.append(''), lines.append('}}}'), lines.append('')
lines.append(''), lines.append('}' '}' '}'), lines.append('')
if __name__ == '__main__':

View File

@ -163,7 +163,7 @@ def format_group(db, notify_changes, is_remote, args):
mi = metadata_from_formats(paths)
if mi.title is None:
return None, set(), set(), False
if (cover_data and not mi.cover_data) or not mi.cover_data[1]:
if cover_data and (not mi.cover_data or not mi.cover_data[1]):
mi.cover_data = 'jpeg', cover_data
format_map = create_format_map(paths)
added_ids, updated_ids, duplicates = do_adding(

View File

@ -46,7 +46,7 @@ class EPUBInput(InputFormatPlugin):
from lxml import etree
idpf_key = opf.raw_unique_identifier
if idpf_key:
idpf_key = re.sub(r'[\u0020\u0009\u000d\u000a]', '', idpf_key)
idpf_key = re.sub(r'[ \t\r\n]', '', idpf_key)
idpf_key = hashlib.sha1(idpf_key.encode('utf-8')).digest()
key = None
for item in opf.identifier_iter():

View File

@ -58,7 +58,7 @@ class HeuristicProcessor:
return '<h2>'+chap+'</h2>\n'
else:
delete_whitespace = re.compile(r'^\s*(?P<c>.*?)\s*$')
delete_quotes = re.compile(r'\'"')
delete_quotes = re.compile(''''"''')
txt_chap = delete_quotes.sub('', delete_whitespace.sub(r'\g<c>', html2text(chap)))
txt_title = delete_quotes.sub('', delete_whitespace.sub(r'\g<c>', html2text(title)))
self.html_preprocess_sections = self.html_preprocess_sections + 1
@ -606,7 +606,7 @@ class HeuristicProcessor:
self.log.warn('Invalid replacement scene break'
' expression, using default')
else:
replacement_break = re.sub(r'(?i)(width=\d+\\%?|width:\s*\d+(\%|px|pt|em)?;?)', '', replacement_break)
replacement_break = re.sub(r'(?i)(width=\d+\%?|width:\s*\d+(\%|px|pt|em)?;?)', '', replacement_break)
divpercent = (100 - width) // 2
hr_open = re.sub(r'45', str(divpercent), hr_open)
scene_break = hr_open+replacement_break+'</div>'

View File

@ -1830,7 +1830,7 @@ class OEBBook:
if is_rtl_lang(lang):
self.spine.page_progression_direction = 'rtl'
except Exception:
raise
pass
def clean_temp_files(self):
for path in self._temp_files:

View File

@ -1340,7 +1340,7 @@ class EpubContainer(Container):
break
if raw_unique_identifier is not None:
idpf_key = raw_unique_identifier
idpf_key = re.sub(r'[\u0020\u0009\u000d\u000a]', '', idpf_key)
idpf_key = re.sub(r'[ \t\r\n]', '', idpf_key)
idpf_key = hashlib.sha1(idpf_key.encode('utf-8')).digest()
return package_id, raw_unique_identifier, idpf_key

View File

@ -433,7 +433,7 @@ def run_gui_(opts, args, app, gui_debug=None):
winutil.prepare_for_restart()
with open(debugfile, 'r+b') as f:
raw = f.read()
raw = re.sub(br'(?<!\r)\n', br'\r\n', raw)
raw = re.sub(br'(?<!\r)\n', b'\r\n', raw)
f.seek(0)
f.truncate()
f.write(raw)

View File

@ -135,7 +135,7 @@ class Image:
return width, height, fmt
def remove_border(self, fuzz=None):
if (fuzz is not None and fuzz < 0) or fuzz > 255:
if fuzz is not None and (fuzz < 0 or fuzz > 255):
fuzz = None
self.img = remove_borders_from_image(self.img, fuzz)
trim = remove_border

View File

@ -324,7 +324,7 @@ def run_test(test_name, verbosity=4, buffer=False):
# calibre-debug -t test_name
which_tests = None
if test_name.startswith('@'):
which_tests = test_name[1:], None
which_tests = (test_name[1:],)
tests = find_tests(which_tests)
if test_name != 'all':
if test_name.startswith('.'):