uniform region (extra-edit)

This commit is contained in:
un-pogaz 2025-01-24 11:14:20 +01:00
parent 5f24dfb868
commit 5540126765
16 changed files with 50 additions and 54 deletions

View File

@ -12,7 +12,7 @@ test_article = None
# test_article = 'https://www.theatlantic.com/health/archive/2020/12/covid-19-second-surge/617415/?utm_source=feed'
# {{{ parse article JSON
# parse article JSON {{{
def process_image_block(lines, block):
caption = block.get('captionText')
caption_lines = []

View File

@ -12,7 +12,7 @@ test_article = None
# test_article = 'https://www.theatlantic.com/health/archive/2020/12/covid-19-second-surge/617415/?utm_source=feed'
# {{{ parse article JSON
# parse article JSON {{{
def process_image_block(lines, block):
caption = block.get('captionText')
caption_lines = []

View File

@ -9,7 +9,7 @@ from calibre import prepare_string_for_xml
from calibre.web.feeds.news import BasicNewsRecipe, classes
# {{{ parse article JSON
# parse article JSON {{{
def process_image_block(lines, block):
caption = block.get('captionText')
caption_lines = []

View File

@ -30,9 +30,8 @@ __all__ = ['pofile', 'POFile', 'POEntry', 'mofile', 'MOFile', 'MOEntry',
# the default encoding to use when encoding cannot be detected
default_encoding = 'utf-8'
# python 2/3 compatibility helpers {{{
PY3 = True
text_type = str
@ -42,9 +41,9 @@ def b(s):
def u(s):
return s
# }}}
# _pofile_or_mofile {{{
def _pofile_or_mofile(f, type, **kwargs):
"""
Internal function used by :func:`polib.pofile` and :func:`polib.mofile` to
@ -67,9 +66,9 @@ def _pofile_or_mofile(f, type, **kwargs):
instance.wrapwidth = kwargs.get('wrapwidth', 78)
return instance
# }}}
# _is_file {{{
def _is_file(filename_or_contents):
"""
Safely returns the value of os.path.exists(filename_or_contents).
@ -85,9 +84,9 @@ def _is_file(filename_or_contents):
except (TypeError, ValueError, UnicodeEncodeError):
return False
# }}}
# function pofile() {{{
def pofile(pofile, **kwargs):
"""
Convenience function that parses the po or pot file ``pofile`` and returns
@ -117,9 +116,9 @@ def pofile(pofile, **kwargs):
"""
return _pofile_or_mofile(pofile, 'pofile', **kwargs)
# }}}
# function mofile() {{{
def mofile(mofile, **kwargs):
"""
Convenience function that parses the mo file ``mofile`` and returns a
@ -151,9 +150,9 @@ def mofile(mofile, **kwargs):
"""
return _pofile_or_mofile(mofile, 'mofile', **kwargs)
# }}}
# function detect_encoding() {{{
def detect_encoding(file, binary_mode=False):
"""
Try to detect the encoding used by the ``file``. The ``file`` argument can
@ -212,9 +211,9 @@ def detect_encoding(file, binary_mode=False):
return enc
return default_encoding
# }}}
# function escape() {{{
def escape(st):
"""
Escapes the characters ``\\\\``, ``\\t``, ``\\n``, ``\\r``, ``\\v``,
@ -229,9 +228,9 @@ def escape(st):
.replace('\f', r'\f')\
.replace('\"', r'\"')
# }}}
# function unescape() {{{
def unescape(st):
"""
Unescapes the characters ``\\\\``, ``\\t``, ``\\n``, ``\\r``, ``\\v``,
@ -256,9 +255,9 @@ def unescape(st):
return m # handles escaped double quote
return re.sub(r'\\(\\|n|t|r|v|b|f|")', unescape_repl, st)
# }}}
# function natural_sort() {{{
def natural_sort(lst):
"""
Sort naturally the given list.
@ -271,11 +270,10 @@ def natural_sort(lst):
return [convert(c) for c in re.split('([0-9]+)', key)]
return sorted(lst, key=alphanum_key)
# }}}
# class _BaseFile {{{
class _BaseFile(list):
"""
Common base class for the :class:`~polib.POFile` and :class:`~polib.MOFile`
@ -626,9 +624,9 @@ class _BaseFile(list):
mixed = mixed.encode(self.encoding)
return mixed
# }}}
# class POFile {{{
class POFile(_BaseFile):
"""
Po (or Pot) file reader/writer.
@ -734,9 +732,9 @@ class POFile(_BaseFile):
if entry.msgid_with_context not in refpot_msgids:
entry.obsolete = True
# }}}
# class MOFile {{{
class MOFile(_BaseFile):
"""
Mo file reader/writer.
@ -807,9 +805,9 @@ class MOFile(_BaseFile):
"""
return []
# }}}
# class _BaseEntry {{{
class _BaseEntry:
"""
Base class for :class:`~polib.POEntry` and :class:`~polib.MOEntry` classes.
@ -942,9 +940,9 @@ class _BaseEntry:
return '{}{}{}'.format(self.msgctxt, "\x04", self.msgid)
return self.msgid
# }}}
# class POEntry {{{
class POEntry(_BaseEntry):
"""
Represents a po file entry.
@ -1186,9 +1184,9 @@ class POEntry(_BaseEntry):
def __hash__(self):
return hash((self.msgid, self.msgstr))
# }}}
# class MOEntry {{{
class MOEntry(_BaseEntry):
"""
Represents a mo file entry.
@ -1221,11 +1219,10 @@ class MOEntry(_BaseEntry):
def __hash__(self):
return hash((self.msgid, self.msgstr))
# }}}
# class _POFileParser {{{
class _POFileParser:
"""
A finite state machine to efficiently and correctly parse po
@ -1658,9 +1655,9 @@ class _POFileParser:
# don't change the current state
return False
# }}}
# class _MOFileParser {{{
class _MOFileParser:
"""
A class to parse binary mo files.

View File

@ -32,7 +32,7 @@ class TagX: # {{{
def __repr__(self):
return 'TAGX(tag=%02d, num_values=%d, bitmask=%r, eof=%d)' % (self.tag,
self.num_values, bin(self.bitmask), self.eof)
# }}}
# }}}
class SecondaryIndexHeader: # {{{
@ -231,7 +231,7 @@ class IndexHeader: # {{{
a('Number of entries in the NCX: %d'% self.ncx_count)
return '\n'.join(ans)
# }}}
# }}}
class Tag: # {{{

View File

@ -518,7 +518,7 @@ def create_margin_files(container):
# }}}
# Link handling {{{
# Link handling {{{
def add_anchors_markup(root, uuid, anchors):
body = last_tag(root)
div = body.makeelement(

View File

@ -498,7 +498,7 @@ def create_theme(folder=None, parent=None):
icon_resource_manager.set_theme()
# }}}
# Choose Theme {{{
# Choose Theme {{{
def download_cover(cover_url, etag=None, cached=b''):

View File

@ -151,7 +151,7 @@ class DateTimeEdit(DateTimeEditBase): # {{{
# }}}
# Number Editor {{{
# Number Editor {{{
def make_clearing_spinbox(spinbox):

View File

@ -454,7 +454,7 @@ class BooksView(QTableView): # {{{
self.preserve_state = partial(PreserveViewState, self)
self.marked_changed_listener = FunctionDispatcher(self.marked_changed)
# {{{ Column Header setup
# Column Header setup {{{
self.can_add_columns = True
self.was_restored = False
self.allow_save_state = True

View File

@ -470,7 +470,7 @@ class PreviewSettings(BasicSettings): # {{{
# }}}
# ToolbarSettings {{{
# ToolbarSettings {{{
class ToolbarList(QListWidget):

View File

@ -402,7 +402,8 @@ class Jump:
jump_to_location(loc)
jump = Jump() # }}}
jump = Jump()
# }}}
# Images {{{

View File

@ -1639,7 +1639,7 @@ class SpellCheck(Dialog):
d.exec()
# }}}
# Find next occurrence {{{
# Find next occurrence {{{
def find_next(word, locations, current_editor, current_editor_name,

View File

@ -814,10 +814,8 @@ class InsertLink(Dialog):
# }}}
# Insert Semantics {{{
class InsertSemantics(Dialog):
class InsertSemantics(Dialog): # {{{
def __init__(self, container, parent=None):
self.container = container

View File

@ -839,7 +839,7 @@ class EbookViewer(MainWindow):
return MainWindow.closeEvent(self, ev)
# }}}
# Auto-hide mouse cursor {{{
# Auto-hide mouse cursor {{{
def setup_mouse_auto_hide(self):
QApplication.instance().installEventFilter(self)
self.cursor_hidden = False

View File

@ -233,7 +233,7 @@ def books(ctx, rd, library_id):
# }}}
# Categories (Tag Browser) {{{
# Categories (Tag Browser) {{{
@endpoint('/ajax/categories/{library_id=None}', postprocess=json)

View File

@ -153,7 +153,7 @@ def get_ranges(headervalue, content_length): # {{{
return result
# }}}
# gzip transfer encoding {{{
# gzip transfer encoding {{{
def gzip_prefix():