@classmethod def _set(cls, dname, value): if dname in cls._fixed_names:
warnings.warn(
f"{cls.__name__}.{dname} {cls._type_desc} is {str(getattr(cls, dname)).upper()}"
f" and cannot be overridden",
stacklevel=3,
) return if dname in cls._all_names:
setattr(cls, dname, value) else: raise ValueError(f"no such {cls._type_desc} {dname!r}")
@lru_cache(maxsize=128) def col(loc: int, strg: str) -> int: """
Returns current column within a string, counting newlines as line separators.
The first column is number 1.
Note: the default parsing behavior is to expand tabs in the input string
before starting the parsing process. See
:class:`ParserElement.parse_string` for more
information on parsing strings containing ``<TAB>`` s, and suggested
methods to maintain a consistent view of the parsed string, the parse
location, and line and column positions within the parsed string. """
s = strg return 1 if 0 < loc < len(s) and s[loc - 1] == "\n"else loc - s.rfind("\n", 0, loc)
@lru_cache(maxsize=128) def lineno(loc: int, strg: str) -> int: """Returns current line number within a string, counting newlines as line separators.
The first line is number 1.
Note - the default parsing behavior is to expand tabs in the input string
before starting the parsing process. See :class:`ParserElement.parse_string` for more information on parsing strings containing ``<TAB>`` s, and
suggested methods to maintain a consistent view of the parsed string, the
parse location, and line and column positions within the parsed string. """ return strg.count("\n", 0, loc) + 1
@lru_cache(maxsize=128) def line(loc: int, strg: str) -> str: """
Returns the line of text containing loc within a string, counting newlines as line separators. """
last_cr = strg.rfind("\n", 0, loc)
next_cr = strg.find("\n", loc) return strg[last_cr + 1 : next_cr] if next_cr >= 0 else strg[last_cr + 1 :]
class UnboundedMemo(dict): """
A memoizing mapping that retains all deleted items """
def __delitem__(self, key): pass
def _escape_regex_range_chars(s: str) -> str: # escape these chars: ^-[] for c in r"\^-[]":
s = s.replace(c, _bslash + c)
s = s.replace("\n", r"\n")
s = s.replace("\t", r"\t") return str(s)
ret = []
s = "".join(sorted(set(s))) if len(s) > 3: for _, chars in itertools.groupby(s, key=is_consecutive):
first = last = next(chars)
last = collections.deque(
itertools.chain(iter([last]), chars), maxlen=1
).pop() if first == last:
ret.append(escape_re_range_char(first)) else:
sep = ""if ord(last) == ord(first) + 1 else"-"
ret.append(
f"{escape_re_range_char(first)}{sep}{escape_re_range_char(last)}"
) else:
ret = [escape_re_range_char(c) for c in s]
return"".join(ret)
def _flatten(ll: list) -> list:
ret = [] for i in ll: if isinstance(i, list):
ret.extend(_flatten(i)) else:
ret.append(i) return ret
def _make_synonym_function(compat_name: str, fn: C) -> C: # In a future version, uncomment the code in the internal _inner() functions # to begin emitting DeprecationWarnings.
# (Presence of 'self' arg in signature is used by explain_exception() methods, so we take # some extra steps to add it if present in decorated function.) if"self" == list(inspect.signature(fn).parameters)[0]:
def replaced_by_pep8(fn: C) -> Callable[[Callable], C]: """
Decorator for pre-PEP8 compatibility synonyms, to link them to the new function. """ returnlambda other: _make_synonym_function(other.__name__, fn)
Messung V0.5
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.21Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.