mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Cleanup previous PR
This commit is contained in:
parent
7e61ea2248
commit
c10832387d
@ -143,7 +143,7 @@ class WSJ(BasicNewsRecipe):
|
|||||||
br.addheaders += [
|
br.addheaders += [
|
||||||
('Accept-Encoding', 'gzip'),
|
('Accept-Encoding', 'gzip'),
|
||||||
('cache-control', 'no-cache'),
|
('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
|
return br
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ class WSJ(BasicNewsRecipe):
|
|||||||
br.addheaders += [
|
br.addheaders += [
|
||||||
('Accept-Encoding', 'gzip'),
|
('Accept-Encoding', 'gzip'),
|
||||||
('cache-control', 'no-cache'),
|
('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
|
return br
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ class WSJ(BasicNewsRecipe):
|
|||||||
br.addheaders += [
|
br.addheaders += [
|
||||||
('Accept-Encoding', 'gzip'),
|
('Accept-Encoding', 'gzip'),
|
||||||
('cache-control', 'no-cache'),
|
('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
|
return br
|
||||||
|
|
||||||
|
@ -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__ = '.'.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})[\'"]([^\'"]+)[\'"]',
|
__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:
|
||||||
|
@ -13,7 +13,7 @@ def parse(raw, parse_dates=True):
|
|||||||
nonlocal current_entry, current_section
|
nonlocal current_entry, current_section
|
||||||
if not stripped_line:
|
if not stripped_line:
|
||||||
return normal
|
return normal
|
||||||
if stripped_line.startswith('{{{'):
|
if stripped_line.startswith('{' '{' '{'):
|
||||||
parts = line.split()[1:]
|
parts = line.split()[1:]
|
||||||
if len(parts) != 2:
|
if len(parts) != 2:
|
||||||
raise ValueError(f'The entry start line is malformed: {line}')
|
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):
|
def in_entry(linenum, line, stripped_line):
|
||||||
nonlocal current_section, current_entry
|
nonlocal current_section, current_entry
|
||||||
if stripped_line == '}}}':
|
if stripped_line == '}' '}' '}':
|
||||||
if current_entry is None:
|
if current_entry is None:
|
||||||
raise ValueError(f'Entry terminator without active entry at line: {linenum}')
|
raise ValueError(f'Entry terminator without active entry at line: {linenum}')
|
||||||
entries.append(current_entry)
|
entries.append(current_entry)
|
||||||
@ -93,7 +93,7 @@ def parse(raw, parse_dates=True):
|
|||||||
if line.startswith('-'):
|
if line.startswith('-'):
|
||||||
finalize_item(item)
|
finalize_item(item)
|
||||||
return start_item(linenum, line, stripped_line)
|
return start_item(linenum, line, stripped_line)
|
||||||
if line.startswith('}}}'):
|
if line.startswith('}' '}' '}'):
|
||||||
return in_entry(linenum, line, stripped_line)
|
return in_entry(linenum, line, stripped_line)
|
||||||
if not stripped_line:
|
if not stripped_line:
|
||||||
if 'description' not in item:
|
if 'description' not in item:
|
||||||
@ -138,7 +138,7 @@ def migrate():
|
|||||||
lines = []
|
lines = []
|
||||||
for entry in entries:
|
for entry in entries:
|
||||||
lines.append('')
|
lines.append('')
|
||||||
lines.append('{{{'+f' {entry["version"]} {entry["date"]}')
|
lines.append('{' '{' '{'+f' {entry["version"]} {entry["date"]}')
|
||||||
for w in ('new features', 'bug fixes'):
|
for w in ('new features', 'bug fixes'):
|
||||||
nf = entry.get(w)
|
nf = entry.get(w)
|
||||||
if nf:
|
if nf:
|
||||||
@ -166,7 +166,7 @@ def migrate():
|
|||||||
lines.append('')
|
lines.append('')
|
||||||
with open(name.replace('yaml', 'txt'), 'w') as f:
|
with open(name.replace('yaml', 'txt'), 'w') as f:
|
||||||
f.write('\n'.join(lines))
|
f.write('\n'.join(lines))
|
||||||
lines.append(''), lines.append('}}}'), lines.append('')
|
lines.append(''), lines.append('}' '}' '}'), lines.append('')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -163,7 +163,7 @@ def format_group(db, notify_changes, is_remote, args):
|
|||||||
mi = metadata_from_formats(paths)
|
mi = metadata_from_formats(paths)
|
||||||
if mi.title is None:
|
if mi.title is None:
|
||||||
return None, set(), set(), False
|
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
|
mi.cover_data = 'jpeg', cover_data
|
||||||
format_map = create_format_map(paths)
|
format_map = create_format_map(paths)
|
||||||
added_ids, updated_ids, duplicates = do_adding(
|
added_ids, updated_ids, duplicates = do_adding(
|
||||||
|
@ -46,7 +46,7 @@ class EPUBInput(InputFormatPlugin):
|
|||||||
from lxml import etree
|
from lxml import etree
|
||||||
idpf_key = opf.raw_unique_identifier
|
idpf_key = opf.raw_unique_identifier
|
||||||
if idpf_key:
|
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()
|
idpf_key = hashlib.sha1(idpf_key.encode('utf-8')).digest()
|
||||||
key = None
|
key = None
|
||||||
for item in opf.identifier_iter():
|
for item in opf.identifier_iter():
|
||||||
|
@ -58,7 +58,7 @@ class HeuristicProcessor:
|
|||||||
return '<h2>'+chap+'</h2>\n'
|
return '<h2>'+chap+'</h2>\n'
|
||||||
else:
|
else:
|
||||||
delete_whitespace = re.compile(r'^\s*(?P<c>.*?)\s*$')
|
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_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)))
|
txt_title = delete_quotes.sub('', delete_whitespace.sub(r'\g<c>', html2text(title)))
|
||||||
self.html_preprocess_sections = self.html_preprocess_sections + 1
|
self.html_preprocess_sections = self.html_preprocess_sections + 1
|
||||||
@ -606,7 +606,7 @@ class HeuristicProcessor:
|
|||||||
self.log.warn('Invalid replacement scene break'
|
self.log.warn('Invalid replacement scene break'
|
||||||
' expression, using default')
|
' expression, using default')
|
||||||
else:
|
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
|
divpercent = (100 - width) // 2
|
||||||
hr_open = re.sub(r'45', str(divpercent), hr_open)
|
hr_open = re.sub(r'45', str(divpercent), hr_open)
|
||||||
scene_break = hr_open+replacement_break+'</div>'
|
scene_break = hr_open+replacement_break+'</div>'
|
||||||
|
@ -1830,7 +1830,7 @@ class OEBBook:
|
|||||||
if is_rtl_lang(lang):
|
if is_rtl_lang(lang):
|
||||||
self.spine.page_progression_direction = 'rtl'
|
self.spine.page_progression_direction = 'rtl'
|
||||||
except Exception:
|
except Exception:
|
||||||
raise
|
pass
|
||||||
|
|
||||||
def clean_temp_files(self):
|
def clean_temp_files(self):
|
||||||
for path in self._temp_files:
|
for path in self._temp_files:
|
||||||
|
@ -1340,7 +1340,7 @@ class EpubContainer(Container):
|
|||||||
break
|
break
|
||||||
if raw_unique_identifier is not None:
|
if raw_unique_identifier is not None:
|
||||||
idpf_key = raw_unique_identifier
|
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()
|
idpf_key = hashlib.sha1(idpf_key.encode('utf-8')).digest()
|
||||||
return package_id, raw_unique_identifier, idpf_key
|
return package_id, raw_unique_identifier, idpf_key
|
||||||
|
|
||||||
|
@ -433,7 +433,7 @@ def run_gui_(opts, args, app, gui_debug=None):
|
|||||||
winutil.prepare_for_restart()
|
winutil.prepare_for_restart()
|
||||||
with open(debugfile, 'r+b') as f:
|
with open(debugfile, 'r+b') as f:
|
||||||
raw = f.read()
|
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.seek(0)
|
||||||
f.truncate()
|
f.truncate()
|
||||||
f.write(raw)
|
f.write(raw)
|
||||||
|
@ -135,7 +135,7 @@ class Image:
|
|||||||
return width, height, fmt
|
return width, height, fmt
|
||||||
|
|
||||||
def remove_border(self, fuzz=None):
|
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
|
fuzz = None
|
||||||
self.img = remove_borders_from_image(self.img, fuzz)
|
self.img = remove_borders_from_image(self.img, fuzz)
|
||||||
trim = remove_border
|
trim = remove_border
|
||||||
|
@ -324,7 +324,7 @@ def run_test(test_name, verbosity=4, buffer=False):
|
|||||||
# calibre-debug -t test_name
|
# calibre-debug -t test_name
|
||||||
which_tests = None
|
which_tests = None
|
||||||
if test_name.startswith('@'):
|
if test_name.startswith('@'):
|
||||||
which_tests = test_name[1:], None
|
which_tests = (test_name[1:],)
|
||||||
tests = find_tests(which_tests)
|
tests = find_tests(which_tests)
|
||||||
if test_name != 'all':
|
if test_name != 'all':
|
||||||
if test_name.startswith('.'):
|
if test_name.startswith('.'):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user