Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 6a26260c authored by Eckhart Arnold's avatar Eckhart Arnold
Browse files

- toolkit.py: added TextView class for non-copy string-slicing

parent b930b98d
...@@ -238,8 +238,9 @@ def add_parser_guard(parser_func): ...@@ -238,8 +238,9 @@ def add_parser_guard(parser_func):
# NOTE: An older and simpler implementation of memoization # NOTE: An older and simpler implementation of memoization
# relied on `parser.visited[location] == node, rest`. Although, # relied on `parser.visited[location] == node, rest`. Although,
# rest is really just a substring of one and the same document, # rest is really just a substring of one and the same document,
# this resulted in an explosion of memory usage. Seems as if # this resulted in an explosion of memory usage. Seems that
# `rext = text[i:]` really copies the sub-string!? # `rext = text[i:]` really copies the sub-string. See:
# https://mail.python.org/pipermail/python-dev/2008-May/079699.html
try: try:
location = len(text) # mind that location is always the distance to the end location = len(text) # mind that location is always the distance to the end
......
...@@ -43,9 +43,9 @@ except ImportError: ...@@ -43,9 +43,9 @@ except ImportError:
import sys import sys
try: try:
from typing import Any, List, Tuple from typing import Any, List, Tuple, Optional
except ImportError: except ImportError:
from .typing34 import Any, List, Tuple from .typing34 import Any, List, Tuple, Optional
__all__ = ('logging', __all__ = ('logging',
'is_logging', 'is_logging',
...@@ -150,6 +150,24 @@ def clear_logs(logfile_types={'.cst', '.ast', '.log'}): ...@@ -150,6 +150,24 @@ def clear_logs(logfile_types={'.cst', '.ast', '.log'}):
os.rmdir(log_dirname) os.rmdir(log_dirname)
class TextView:
__slots__ = ['text', 'begin', 'end']
def __init__(self, text: str, begin: Optional[int] = 0, end: Optional[int] = None) -> None:
self.text = text # type: str
self.begin = begin or 0 # type: int
self.end = end or len(text) # type: int
def __str__(self):
return self.text[self.begin:self.end]
def __getitem__(self, index):
assert isinstance(index, slice), "Minimal implementation of TextView just allows slicing."
start = index.start or 0
stop = index.stop or (self.end - self.begin)
return TextView(self.text, self.begin + start, self.begin + stop)
# def repr_call(f, parameter_list) -> str: # def repr_call(f, parameter_list) -> str:
# """Turns a list of items into a string resembling the parameter # """Turns a list of items into a string resembling the parameter
# list of a function call by omitting default values at the end: # list of a function call by omitting default values at the end:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment