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 333f4a9a authored by di68kap's avatar di68kap
Browse files

- corrections for stringview.py

parent ac1e1dbf
......@@ -8,7 +8,7 @@ import cython
# type hints for Cython python -> C compiler to speed up the most
# critical code paths of stringview.py.
# see https://cython.readthedocs.io/en/latest/src/tutorial/pure.html
cdef int first_char(str text, int begin, int end)
......@@ -19,8 +19,6 @@ cdef int pack_index(int index, int length)
@cython.locals(cbegin=cython.int, cend=cython.int)
cpdef real_indices(begin, end, int length)
# cdefs for class StringView: https://cython.readthedocs.io/en/latest/src/tutorial/pure.html
cdef class StringView:
cdef str _text
cdef int _begin, _end, _len
......
......@@ -164,13 +164,6 @@ class StringView: # collections.abc.Sized
except AttributeError:
return StringView(self._text, self._begin + index, self._begin + index + 1)
def get_begin(self) -> int:
"""Returns the offset of the StringView. This is needed to correct
the absolute offsets that the match objects of regular expression
objects return.
"""
return self._begin
def get_text(self) -> str:
"""Returns the underlying string."""
return self._text
......@@ -191,6 +184,7 @@ class StringView: # collections.abc.Sized
start, end = real_indices(start, end, self._len)
return self._text.count(sub, self._begin + start, self._begin + end)
@cython.locals(_start=cython.int, _end=cython.int)
def find(self, sub: str, start: Optional[int] = None, end: Optional[int] = None) -> int:
"""Returns the lowest index in S where substring `sub` is found,
such that `sub` is contained within S[start:end]. Optional
......@@ -205,8 +199,8 @@ class StringView: # collections.abc.Sized
elif start is None and end is None:
return self._text.find(sub, self._begin, self._end) - self._begin
else:
start, end = real_indices(start, end, self._len)
return self._text.find(sub, self._begin + start, self._begin + end) - self._begin
_start, _end = real_indices(start, end, self._len)
return self._text.find(sub, self._begin + _start, self._begin + _end) - self._begin
def rfind(self, sub: str, start: Optional[int] = None, end: Optional[int] = None) -> int:
"""Returns the highest index in S where substring `sub` is found,
......
......@@ -952,7 +952,7 @@ def parse_sxpr(sxpr: Union[str, StringView]) -> Node:
if match is None:
raise AssertionError('Malformed S-expression Node-tagname or identifier expected, '
'not "%s"' % sxpr[:40].replace('\n', ''))
end = match.end() - sxpr.get_begin()
end = sxpr.index(match.end())
tagname = sxpr[:end]
name, class_name = (tagname.split(':') + [''])[:2]
sxpr = sxpr[end:].strip()
......@@ -986,14 +986,14 @@ def parse_sxpr(sxpr: Union[str, StringView]) -> Node:
for qtmark in ['"""', "'''", '"', "'"]:
match = sxpr.match(re.compile(qtmark + r'.*?' + qtmark, re.DOTALL))
if match:
end = match.end() - sxpr.get_begin()
end = sxpr.index(match.end())
i = len(qtmark)
lines.append(str(sxpr[i:end - i]))
sxpr = sxpr[end:].strip()
break
else:
match = sxpr.match(re.compile(r'(?:(?!\)).)*', re.DOTALL))
end = match.end() - sxpr.get_begin()
end = sxpr.index(match.end())
lines.append(str(sxpr[:end]))
sxpr = sxpr[end:]
result = "\n".join(lines)
......@@ -1026,7 +1026,7 @@ def parse_xml(xml: Union[str, StringView]) -> Node:
for match in s.finditer(re.compile(r'\s*(?P<attr>\w+)\s*=\s*"(?P<value>.*)"\s*')):
d = match.groupdict()
attributes[d['attr']] = d['value']
restart = match.end() - s.get_begin()
restart = s.index(match.end())
return (s[restart:], attributes)
def parse_opening_tag(s: StringView) -> Tuple[StringView, str, OrderedDict, bool]:
......@@ -1038,7 +1038,7 @@ def parse_xml(xml: Union[str, StringView]) -> Node:
match = s.match(re.compile(r'<\s*(?P<tagname>[\w:]+)\s*'))
assert match
tagname = match.groupdict()['tagname']
section = s[match.end() - s.get_begin():]
section = s[s.index(match.end()):]
s, attributes = parse_attributes(section)
i = s.find('>')
assert i >= 0
......@@ -1051,7 +1051,7 @@ def parse_xml(xml: Union[str, StringView]) -> Node:
match = s.match(re.compile(r'</\s*(?P<tagname>[\w:]+)>'))
assert match
tagname = match.groupdict()['tagname']
return s[match.end() - s.get_begin():], tagname
return s[s.index(match.end()):], tagname
def parse_leaf_content(s: StringView) -> Tuple[StringView, StringView]:
"""Parses a piece of the content of a tag, just until the next opening,
......
......@@ -32,7 +32,7 @@ import DHParser.log
from DHParser.log import log_parsing_history
LOGGING = True
LOGGING = False
if not DHParser.dsl.recompile_grammar('LaTeX.ebnf', force=False): # recompiles Grammar only if it has changed
print('\nErrors while recompiling "LaTeX.ebnf":\n--------------------------------------\n\n')
......
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