Beispiel #1
0
def parse_plate(lines, plate):
    if not plate:
        return None

    section_indexes = []

    found = False
    for line_no in range(len(lines)):
        line = lines[line_no]
        vpr = ''

        if '====begin' in line:
            section_indexes.append(line_no - 1)
            found = False
        elif 'get fifo data ={' in line:
            match = re.search(r"'ComLicence': u'(.*?)'", line)
            if match:
                vpr = match.group(1).decode('unicode-escape')
            else:
                match = re.search(r"'ComLicence2': u'(.*?)'", line)
                if match:
                    vpr = match.group(1).decode('unicode-escape')
            if plate in vpr:
                found = True
        elif '双识别第二次识别数据处理流程' in line:
            found = False
        elif '====end' in line:
            if found:
                section_indexes.append(line_no + 1)
            else:
                section_indexes.pop()
            found = False

    sections = []

    for lno in range(len(section_indexes)):
        if lno % 2 == 1:
            section_lines = lines[section_indexes[lno - 1]:section_indexes[lno]]
            s = Section.from_lines(section_lines, _parser)

            parsed_info = {}
            for lg in s.logs():
                extra = lg[2]
                parsed_info.update(extra)
            sections.append(parsed_info)

            if lno == len(section_indexes) - 1:
                break

    return sections
Beispiel #2
0
def parse_all(lines):
    section_indexes = Queue()

    for line_no in range(len(lines)):
        line = lines[line_no]

        if '====begin' in line:
            section_indexes.put(line_no - 1)
        if '====end' in line:
            section_indexes.put(line_no + 1)

    sections = []

    while not section_indexes.empty():
        # this could happen when logfile is damaged
        if section_indexes.qsize() == 1:
            break
        section_lines = lines[section_indexes.get():section_indexes.get()]
        sections.append(Section.from_lines(section_lines, _parser))

    return sections