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 cd444a1e authored by eckhart's avatar eckhart
Browse files

- experimental html support

parent 772704b2
...@@ -146,6 +146,12 @@ class HistoryRecord: ...@@ -146,6 +146,12 @@ class HistoryRecord:
ERROR = "ERROR" ERROR = "ERROR"
FAIL = "FAIL" FAIL = "FAIL"
Snapshot = collections.namedtuple('Snapshot', ['line', 'column', 'stack', 'status', 'text']) Snapshot = collections.namedtuple('Snapshot', ['line', 'column', 'stack', 'status', 'text'])
HTML_LEAD_IN = ('<html>\n<head>\n<meta charset="utf-8"/>\n<style>\n'
'td.line, td.column {font-family:mono;color:darkgrey}\n'
'td.stack{font-family:serif}\ntd.status{font-weight:bold}\n'
'ts.text{font-family:mono;color:darkblue}'
'\n</style>\n</head>\n<body>\n')
HTML_LEAD_OUT = '\n</table>\n</body>\n</html>\n'
def __init__(self, call_stack: List['Parser'], node: Node, text: StringView) -> None: def __init__(self, call_stack: List['Parser'], node: Node, text: StringView) -> None:
# copy call stack, dropping uninformative Forward-Parsers # copy call stack, dropping uninformative Forward-Parsers
...@@ -170,9 +176,10 @@ class HistoryRecord: ...@@ -170,9 +176,10 @@ class HistoryRecord:
excerpt = excerpt.replace('\n', '\\n') excerpt = excerpt.replace('\n', '\\n')
return self.Snapshot(self.line_col[0], self.line_col[1], self.stack, self.status, excerpt) return self.Snapshot(self.line_col[0], self.line_col[1], self.stack, self.status, excerpt)
def as_html_table_row(self) -> str: def as_html_tr(self) -> str:
escaped = tuple(html.escape(str(item)) for item in self.as_tuple()) tpl = self.as_tuple()
return "<td>%i</td><td>%i</td> <td>%s</td> <td>%s</td> <td>%s</td>" % escaped return ''.join(['<tr>'] + [('<td class="%s">%s</td>' % (cls, html.escape(str(item))))
for cls, item in zip(tpl._fields, tpl)] + ['</tr>'])
def err_msg(self) -> str: def err_msg(self) -> str:
return self.ERROR + ": " + "; ".join( return self.ERROR + ": " + "; ".join(
...@@ -909,18 +916,24 @@ class Grammar: ...@@ -909,18 +916,24 @@ class Grammar:
else (len(self.document__) + 1) else (len(self.document__) + 1)
def log_parsing_history__(self, log_file_name: str = '') -> None: def log_parsing_history__(self, log_file_name: str = '', html: bool=True) -> None:
""" """
Writes a log of the parsing history of the most recently parsed Writes a log of the parsing history of the most recently parsed
document. document.
""" """
def write_log(history, log_name): def write_log(history, log_name):
path = os.path.join(log_dir(), log_name + "_parser.log") htm = '.html' if html else ''
path = os.path.join(log_dir(), log_name + "_parser.log" + htm)
if os.path.exists(path): if os.path.exists(path):
os.remove(path) os.remove(path)
print('WARNING: Log-file "%s" already existed and was deleted.' % path) print('WARNING: Log-file "%s" already existed and was deleted.' % path)
if history: if history:
with open(path, "w", encoding="utf-8") as f: with open(path, "w", encoding="utf-8") as f:
if html:
f.write(HistoryRecord.HTML_LEAD_IN)
f.write("\n".join(history))
f.write(HistoryRecord.HTML_LEAD_OUT)
else:
f.write("\n".join(history)) f.write("\n".join(history))
if is_logging(): if is_logging():
...@@ -933,7 +946,7 @@ class Grammar: ...@@ -933,7 +946,7 @@ class Grammar:
log_file_name = log_file_name[:-4] log_file_name = log_file_name[:-4]
full_history, match_history, errors_only = [], [], [] full_history, match_history, errors_only = [], [], []
for record in self.history__: for record in self.history__:
line = str(record) line = record.as_html_tr() if html else str(record)
full_history.append(line) full_history.append(line)
if record.node and record.node.parser.ptype != WHITESPACE_PTYPE: if record.node and record.node.parser.ptype != WHITESPACE_PTYPE:
match_history.append(line) match_history.append(line)
......
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