Beispiel #1
0
def __option_parser__(parser=None):
    if parser is None: parser = OptionParser(version=__version__)
    parser = tdbparse.__option_parser__(parser)
    tdbxml_group = OptionGroup(parser, 'tdbxml module (%s)' % (__version__,))
    tdbxml_group.add_option('-' + TdbxmlConstants.OPTION_STYLE_SHORT,
                            '--' + TdbxmlConstants.OPTION_STYLE,
                            choices=TdbxmlConstants.OPTION_STYLES,
                            default=TdbxmlConstants.OPTION_STYLE_DEFAULT,
                            help=TdbxmlConstants.OPTION_STYLE_HELP)
    tdbxml_group.add_option('-' + TdbxmlConstants.OPTION_NO_PUB_DOWN_SHORT,
                            '--' + TdbxmlConstants.OPTION_NO_PUB_DOWN,
                            action='store_true',
                            help=TdbxmlConstants.OPTION_NO_PUB_DOWN_HELP)
    tdbxml_group.add_option('-' + TdbxmlConstants.OPTION_INPUT_FILE_SHORT,
                            '--' + TdbxmlConstants.OPTION_INPUT_FILE,
                            action='store',
                            dest='input_file',
                            help=TdbxmlConstants.OPTION_INPUT_FILE_HELP
                            )
    tdbxml_group.add_option('-' + TdbxmlConstants.OPTION_OUTPUT_FILE_SHORT,
                            '--' + TdbxmlConstants.OPTION_OUTPUT_FILE,
                            action='store',
                            dest='output_file',
                            help=TdbxmlConstants.OPTION_OUTPUT_FILE_HELP
                            )
    parser.add_option_group(tdbxml_group)
    return parser
Beispiel #2
0
def __option_parser__(parser=None):
    if parser is None: parser = OptionParser(version=__version__)
    parser = tdbparse.__option_parser__(parser)
    tdbout_group = OptionGroup(parser, 'tdbout module (%s)' % (__version__,))
    tdbout_group.add_option('-' + TdboutConstants.OPTION_STYLE_SHORT,
                            '--' + TdboutConstants.OPTION_STYLE,
                            choices=TdboutConstants.OPTION_STYLES,
                            help=TdboutConstants.OPTION_STYLE_HELP)
    tdbout_group.add_option('-' + TdboutConstants.OPTION_FIELDS_SHORT,
                            '--' + TdboutConstants.OPTION_FIELDS,
                            help=TdboutConstants.OPTION_FIELDS_HELP)
    tdbout_group.add_option('-' + TdboutConstants.OPTION_INPUT_FILE_SHORT,
                            '--' + TdboutConstants.OPTION_INPUT_FILE,
                            action='store',
                            dest='input_file',
                            help=TdboutConstants.OPTION_INPUT_FILE_HELP
                            )
    tdbout_group.add_option('-' + TdboutConstants.OPTION_OUTPUT_FILE_SHORT,
                            '--' + TdboutConstants.OPTION_OUTPUT_FILE,
                            action='store',
                            dest='output_file',
                            help=TdboutConstants.OPTION_OUTPUT_FILE_HELP
                            )
    def __synonym_auid(opt, str, val, par):
        if getattr(par.values, TdboutConstants.OPTION_STYLE, None): par.error('cannot specify -%s and -%s together' % (TdboutConstants.OPTION_AUID_SHORT, TdboutConstants.OPTION_STYLE_SHORT))
        setattr(par.values, TdboutConstants.OPTION_STYLE, TdboutConstants.OPTION_STYLE_LIST)
        setattr(par.values, TdboutConstants.OPTION_FIELDS, 'auid')
    tdbout_group.add_option('-' + TdboutConstants.OPTION_AUID_SHORT,
                            '--' + TdboutConstants.OPTION_AUID,
                            type=None,
                            action='callback',
                            help=TdboutConstants.OPTION_AUID_HELP,
                            callback=__synonym_auid) 
    def __synonym_auidplus(opt, str, val, par):
        if getattr(par.values, TdboutConstants.OPTION_STYLE, None): par.error('cannot specify -%s and -%s together' % (TdboutConstants.OPTION_AUIDPLUS_SHORT, TdboutConstants.OPTION_STYLE_SHORT))
        setattr(par.values, TdboutConstants.OPTION_STYLE, TdboutConstants.OPTION_STYLE_LIST)
        setattr(par.values, TdboutConstants.OPTION_FIELDS, 'auidplus')
    tdbout_group.add_option('-' + TdboutConstants.OPTION_AUIDPLUS_SHORT,
                            '--' + TdboutConstants.OPTION_AUIDPLUS,
                            type=None,
                            action='callback',
                            help=TdboutConstants.OPTION_AUIDPLUS_HELP,
                            callback=__synonym_auidplus)
    def __synonym_csv(opt, str, val, par):
        if getattr(par.values, TdboutConstants.OPTION_STYLE, None): par.error('cannot specify -%s and -%s together' % (TdboutConstants.OPTION_CSV_SHORT, TdboutConstants.OPTION_STYLE_SHORT))
        setattr(par.values, TdboutConstants.OPTION_STYLE, TdboutConstants.OPTION_STYLE_CSV)
        setattr(par.values, TdboutConstants.OPTION_FIELDS, val)
    tdbout_group.add_option('-' + TdboutConstants.OPTION_CSV_SHORT,
                            '--' + TdboutConstants.OPTION_CSV,
                            type='string',
                            metavar=TdboutConstants.OPTION_CSV_META,
                            action='callback',
                            help=TdboutConstants.OPTION_CSV_HELP,
                            callback=__synonym_csv) 
    def __synonym_list(opt, str, val, par):
        if getattr(par.values, TdboutConstants.OPTION_STYLE, None): par.error('cannot specify -%s and -%s together' % (TdboutConstants.OPTION_LIST_SHORT, TdboutConstants.OPTION_STYLE_SHORT))
        setattr(par.values, TdboutConstants.OPTION_STYLE, TdboutConstants.OPTION_STYLE_LIST)
        setattr(par.values, TdboutConstants.OPTION_FIELDS, val)
    tdbout_group.add_option('-' + TdboutConstants.OPTION_LIST_SHORT,
                            '--' + TdboutConstants.OPTION_LIST,
                            type='string',
                            metavar=TdboutConstants.OPTION_LIST_META,
                            action='callback',
                            help=TdboutConstants.OPTION_LIST_HELP,
                            callback=__synonym_list) 
    def __synonym_tsv(opt, str, val, par):
        if getattr(par.values, TdboutConstants.OPTION_STYLE, None): par.error('cannot specify -%s and -%s together' % (TdboutConstants.OPTION_TSV_SHORT, TdboutConstants.OPTION_STYLE_SHORT))
        setattr(par.values, TdboutConstants.OPTION_STYLE, TdboutConstants.OPTION_STYLE_TSV)
        setattr(par.values, TdboutConstants.OPTION_FIELDS, val)
    tdbout_group.add_option('-' + TdboutConstants.OPTION_TSV_SHORT,
                            '--' + TdboutConstants.OPTION_TSV,
                            type='string',
                            metavar=TdboutConstants.OPTION_TSV_META,
                            action='callback',
                            help=TdboutConstants.OPTION_TSV_HELP,
                            callback=__synonym_tsv) 
    tdbout_group.add_option('-' + TdboutConstants.OPTION_NAMES_SHORT,
                            '--' + TdboutConstants.OPTION_NAMES,
                            action='store_true',
                            help=TdboutConstants.OPTION_NAMES_HELP)
    tdbout_group.add_option('-' + TdboutConstants.OPTION_WARNINGS_SHORT,
                            '--' + TdboutConstants.OPTION_WARNINGS,
                            action='store_true',
                            help=TdboutConstants.OPTION_WARNINGS_HELP)
    tdbout_group.add_option('-' + TdboutConstants.OPTION_JOURNALS_SHORT,
                            '--' + TdboutConstants.OPTION_JOURNALS,
                            action='store_true',
                            help=TdboutConstants.OPTION_JOURNALS_HELP)
    parser.add_option_group(tdbout_group)
    return parser