Next / Previous / Contents / TCC Help System / NM Tech homepage

4.13. Args._buildParser(): Build the argument parser

pyrang
# - - -   A r g s . _ b u i l d P a r s e r

    def _buildParser(self):
        '''Set up the argparse.ArgumentParser instance.
        '''
        #-- 1
        # [ parser  :=  an argparse.ArgumentParser instance ]
        parser = argparse.ArgumentParser(
            description="Generate Python constants for XML element"
            "and attribute names in a Relax NG schema")

        #-- 2
        # [ parser  +:=  an option argument that stores in
        #       self.prefix, with default value "" ]
        parser.add_argument(self.PREFIX_SHORT, self.PREFIX_LONG,
            dest="prefix", metavar="PREFIX", default="",
            help="String to be prepended to each generated name")

        #-- 3
        # [ parser  +:=  an option argument that stores in
        #       self.outFileName, with default value None ]
        parser.add_argument(self.OUT_SHORT, self.OUT_LONG,
            dest="outFileName", metavar="OUTFILE",
            help="Output file name")

        #-- 4
        # [ parser  +:=  a required positional argument that stores
        #       in self.inFileName ]
        parser.add_argument(self.IN_FILE_ARG, metavar="INFILE",
            help="Input file name")

        #-- 5
        return parser