<commit_before>import argparse

class ParserResource(object):

    def __init__(self, command, positional=None, *options):
        self.command = command
        self.positional = positional
        self.option = dict((option[0], option[1]) for option in options)

    @property
    def help_(self):
        x = self.positional[0].upper() if self.positional else ''
        for name in self.option:
            x += (' --%s %s' % (name, name.upper()))
        return x

class Parser(argparse.ArgumentParser):

    resources = (ParserResource('poc', ('handle', 'POC Handle')),
                 ParserResource('org', ('handle', 'Org handle')),
                 ParserResource('net', ('handle', 'Net handle')),
                 ParserResource('asn', ('handle', 'ASN handle')),
                 ParserResource('customer', ('handle', 'Customer handle')),
                 ParserResource('rdns', ('name', 'Delegation name')),

                 ParserResource('orgs', None,
                                ('handle', 'Org handle'),
                                ('name', 'Org Name'),
                                ('dba', 'Org DBA')))

    def populate(self):
        self.add_argument('--output', choices=('xml', 'text', 'html'),
                          default='text')
        subparsers = self.add_subparsers(title='Commands', metavar='',
                                         dest='call')
        for resource in self.resources:
            self._add_subparser(subparsers, resource)

    def run(self):
        return self.parse_args()

    def _add_subparser(self, subparsers, resource):
        subparser = subparsers.add_parser(resource.command,
                                          help=resource.help_)
        if resource.positional:
            subparser.add_argument(resource.positional[0],
                                   metavar=resource.positional[0].upper(),
                                   help=resource.positional[1])
        for name, description in resource.option.iteritems():
            subparser.add_argument(name, metavar=name.upper(),
                                   help=description)

    def _add_orgs(self, subparsers):
        subparser = subparsers.add_parser('orgs', help='--handle HANDLE --name NAME --dba DBA')
        subparser.add_argument('--handle', help='Org handle')
        subparser.add_argument('--name', help='Org name')
        subparser.add_argument('--dba', help='Org DBA')

    def _add_org_related(self, subparsers):
        subparser = subparsers.add_parser('org-related', help='--handle HANDLE --resource RESOURCE')
        subparser.add_argument('--handle', help='Org handle')
        subparser.add_argument('--resource', help='Resource')<commit_msg>correct addition of options with "--"<commit_after>import argparse

class ParserResource(object):

    def __init__(self, command, positional=None, *options):
        self.command = command
        self.positional = positional
        self.option = dict((option[0], option[1]) for option in options)

    @property
    def help_(self):
        h = self.positional[0].upper() if self.positional else ''
        for name in self.option:
            h += (' --%s %s' % (name, name.upper()))
        return h

class Parser(argparse.ArgumentParser):

    resources = (ParserResource('poc', ('handle', 'POC Handle')),
                 ParserResource('org', ('handle', 'Org handle')),
                 ParserResource('net', ('handle', 'Net handle')),
                 ParserResource('asn', ('handle', 'ASN handle')),
                 ParserResource('customer', ('handle', 'Customer handle')),
                 ParserResource('rdns', ('name', 'Delegation name')),

                 ParserResource('orgs', None,
                                ('handle', 'Org handle'),
                                ('name', 'Org Name'),
                                ('dba', 'Org DBA')))

    def populate(self):
        self.add_argument('--output', choices=('xml', 'text', 'html'),
                          default='text')
        subparsers = self.add_subparsers(title='Commands', metavar='',
                                         dest='call')
        for resource in self.resources:
            self._add_subparser(subparsers, resource)

    def run(self):
        return self.parse_args()

    def _add_subparser(self, subparsers, resource):
        subparser = subparsers.add_parser(resource.command,
                                          help=resource.help_)
        if resource.positional:
            subparser.add_argument(resource.positional[0],
                                   metavar=resource.positional[0].upper(),
                                   help=resource.positional[1])
        for name, description in resource.option.iteritems():
            subparser.add_argument('--%s' % name, metavar=name.upper(),
                                   help=description)

    def _add_orgs(self, subparsers):
        subparser = subparsers.add_parser('orgs', help='--handle HANDLE --name NAME --dba DBA')
        subparser.add_argument('--handle', help='Org handle')
        subparser.add_argument('--name', help='Org name')
        subparser.add_argument('--dba', help='Org DBA')

    def _add_org_related(self, subparsers):
        subparser = subparsers.add_parser('org-related', help='--handle HANDLE --resource RESOURCE')
        subparser.add_argument('--handle', help='Org handle')
        subparser.add_argument('--resource', help='Resource')
{'fraction_non_alphanumeric': 0.1382842509603073, 'fraction_numerical': 0.002194988110481068, 'mean_word_length': 2.0513392857142856, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '840556', 'n_tokens_mistral': 1492, 'n_tokens_neox': 1421, 'n_words': 309}