#!/usr/bin/env python3 # Copyright (c) 2008-10 Qtrac Ltd. All rights reserved. # This program or module is free software: you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. It is provided for educational # purposes and is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. import optparse import os import queue import threading import xml.etree.ElementTree import xml.parsers.expat import Util if hasattr(xml.etree.ElementTree, "ParseError"): # Python 3.2 class Worker(threading.Thread): def __init__(self, work_queue, results_queue, number): super().__init__() self.work_queue = work_queue self.results_queue = results_queue self.number = number def run(self): while True: try: filename = self.work_queue.get() self.process(filename) finally: self.work_queue.task_done() def process(self, filename): tags = set() try: with open(filename, encoding="utf8", errors="ignore") as fh: line = fh.readline() if not line.startswith("