def extract_plugin_log(data, plugin): from patchbot import plugin_boundary start = plugin_boundary(plugin) + "\n" end = plugin_boundary(plugin, end=True) + "\n" all = [] include = False for line in StringIO(data): if line == start: include = True if include: all.append(line) if line == end: break return ''.join(all)
def shorten(lines): timing = re.compile(r'\s*\[(\d+ tests?, )?\d+\.\d* s\]\s*$') skip = re.compile(r'(sage -t.*\(skipping\))|(byte-compiling)|(copying)|(\S+: \d+% \(\d+ of \d+\)|(Build finished. The built documents can be found in.*)|(\[.........\] .*)|(cp.*/mac-app/.*)|(creating.*site-packages/sage.*)|(mkdir.*)|(creating build/.*)|(;;;.*))$') gcc = re.compile('(gcc)|(g\+\+)') prev = None in_plugin = False from patchbot import plugin_boundary plugin_start = re.compile(plugin_boundary('.*')) plugin_end = re.compile(plugin_boundary('.*', end=True)) for line in StringIO(lines): if line.startswith('='): if plugin_end.match(line): if prev: yield prev prev = None in_plugin = False elif plugin_start.match(line): if prev: yield prev prev = None yield line in_plugin = True if in_plugin: prev = line continue if skip.match(line): pass elif prev is None: prev = line elif prev.startswith('sage -t') and timing.match(line): prev = None elif prev.startswith('python `which cython`') and '-->' in line: prev = None elif gcc.match(prev) and (gcc.match(line) or line.startswith('Time to execute')): prev = line else: if prev is not None: yield prev prev = line if prev is not None: yield prev