import os, re, StringIO, time from portage_database import PortageDatabaseConnection class PortageProcessor: _r = { 'warnings' : re.compile(r"(Tinderbox QA Warning!|QA Notice: (Pre-stripped|file does not exist|command not found|USE flag|Files built without respecting|The following files)|linux_config_exists|will always overflow|called with bigger|maintainer mode detected|econf called in src_compile|udev rules should be installed)"), 'testfailed' : re.compile(r"^ \* ERROR: .* failed \(test phase\):"), 'failed' : re.compile(r"^ \* ERROR: .* failed"), 'collision' : re.compile(r"Detected file collision"), 'maintainer' : re.compile(r"^ \* Maintainer: ([a-zA-Z0-9.@_+-]+)(?: ([a-zA-Z0-9.@_+,-]+))?$"), 'escapes' : re.compile(r"\x1b\[[^\x40-\x7e]*[\x40-\x7e]") } def __init__(self, storage): self.storage = storage def process(self, request, source, db): db = PortageDatabaseConnection(db) group_id = db.insert_group(source, request.group_name, 'portage', int(time.time())) matches = 0 pkg_failed = False test_failed = False collision = False bug_assignee = 'bug-wranglers@gentoo.org' bug_cc = '' for f in request.files: # TODO: look at proper HTML generation methods: # (*) either XHTML via xml.etree # (*) or Jinja2 (is it possible to parse and generate in one pass?) output = StringIO.StringIO() output.write('''\