@@ -0,0 +1,2562 @@
+#!/usr/bin/env python%0A%0Aimport os%0Aimport argparse%0Aimport logging%0A%0Aclass ArgHandler(object):%0A    %0A    def __init__(self, arglist):%0A        self.arglist = arglist%0A%0A        # setup argparse%0A        self.parser = argparse.ArgumentParser(description=%5C%0A                'Specify source directory/directories for xml files to be parsed')%0A        self.parser.add_argument('--directory','-d', type=str, nargs='+', default='.',%0A                help='comma separated list of directories relative to $PATENTROOT that %5C%0A                parse.py will search for .xml files')%0A        self.parser.add_argument('--patentroot','-p', type=str, nargs='?',%0A                default=os.environ%5B'PATENTROOT'%5D %5C%0A                if os.environ.has_key('PATENTROOT') else '/',%0A                help='root directory of all patent files/directories')%0A        self.parser.add_argument('--xmlregex','-x', type=str, %0A                nargs='?', default=r%22ipg%5Cd%7B6%7D.xml%22,%0A                help='regex used to match xml files in each directory')%0A        self.parser.add_argument('--verbosity', '-v', type = int,%0A                nargs='?', default=0,%0A                help='Set the level of verbosity for the computation. The higher the %5C%0A                verbosity level, the less restrictive the print policy. 0 (default) %5C%0A                = error, 1 = warning, 2 = info, 3 = debug')%0A%0A        # parse arguments and assign values%0A        args = self.parser.parse_args(self.arglist)%0A        self.directories = args.directory%0A        self.xmlregex = args.xmlregex%0A        self.patentroot = args.patentroot%0A%0A        # adjust verbosity levels based on specified input%0A        logging_levels = %7B0: logging.ERROR,%0A                          1: logging.WARNING,%0A                          2: logging.INFO,%0A                          3: logging.DEBUG%7D%0A        self.verbosity = logging_levels%5Bargs.verbosity%5D%0A%0A    def invalid_config(self):%0A        # double check that variables are actually set%0A        # we ignore the verbosity argument when determining%0A        # if any variables have been set by the user%0A        specified = %5Barg for arg in self.arglist if arg.startswith('-')%5D%0A        nonverbose = %5Bopt for opt in specified if '-v' not in opt%5D%0A        return len(nonverbose) == 0%0A        %0A    def get_directory_list(self):%0A        return self.directories%0A%0A    def get_xmlregex(self):%0A        return self.xmlregex%0A%0A    def get_patentroot(self):%0A        return self.patentroot%0A%0A    def get_verbosity(self):%0A        return self.verbosity%0A%0A    def get_help(self):%0A        self.parser.print_help()%0A        sys.exit(1)%0A

add file for handling parse.py arguments