我们从Python开源项目中,提取了以下12个代码示例,用于说明如何使用configargparse.getArgumentParser()。
def get_config(): cwd = os.getcwd() p = configargparse.getArgumentParser(default_config_files=[os.path.join(cwd, 'conf.ini')]) p.add('-c', '--my-config', required=False, is_config_file=True, help='config file path') p.add_argument('--data_dir', type=str, help='where data files are located') p.add_argument('--issuer_certs_url', type=str, help='issuer certificates URL') p.add_argument('--template_dir', type=str, help='the template output directory') p.add_argument('--template_file_name', type=str, help='the template file name') p.add_argument('--hash_emails', action='store_true', help='whether to hash emails in the certificate') p.add_argument('--additional_per_recipient_fields', action=helpers.make_action('per_recipient_fields'), help='additional per-recipient fields') p.add_argument('--unsigned_certificates_dir', type=str, help='output directory for unsigned certificates') p.add_argument('--roster', type=str, help='roster file name') args, _ = p.parse_known_args() args.abs_data_dir = os.path.abspath(os.path.join(cwd, args.data_dir)) return args
def get_config(): cwd = os.getcwd() p = configargparse.getArgumentParser(default_config_files=[os.path.join(cwd, 'conf.ini')]) p.add('-c', '--my-config', required=False, is_config_file=True, help='config file path') p.add_argument('--data_dir', type=str, help='where data files are located') p.add_argument('--issuer_certs_url', type=str, help='issuer certificates URL') p.add_argument('--template_dir', type=str, help='the template output directory') p.add_argument('--template_file_name', type=str, help='the template file name') p.add_argument('--hash_emails', action='store_true', help='whether to hash emails in the certificate') p.add_argument('--additional_per_recipient_fields', action=helpers.make_action('per_recipient_fields'), help='additional per-recipient fields') p.add_argument('--unsigned_certificates_dir', type=str, help='output directory for unsigned certificates') p.add_argument('--roster', type=str, help='roster file name') p.add_argument('--filename_format', type=str, help='how to format certificate filenames (one of certname_identity or uuid)') p.add_argument('--no_clobber', action='store_true', help='whether to overwrite existing certificates') args, _ = p.parse_known_args() args.abs_data_dir = os.path.abspath(os.path.join(cwd, args.data_dir)) return args
def get_config(): base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) p = configargparse.getArgumentParser(default_config_files=[os.path.join(base_dir, 'conf.ini')]) p.add('-c', '--my-config', required=True, is_config_file=True, help='config file path') p.add_argument('-k', '--issuer_address', type=str, required=True, help='the issuer\'s Bitcoin address that will be used to issue the certificates') p.add_argument('-r', '--revocation_address', type=str, required=True, help='the issuer\'s Bitcoin revocation address that can be used to revocate the certificates') p.add_argument('-d', '--issuer_id', type=str, required=True, help='the issuer\'s publicly accessible identification file; i.e. URL of the file generated by this tool') p.add_argument('-u', '--issuer_url', type=str, help='the issuers main URL address') p.add_argument('-l', '--issuer_certs_url', type=str, help='the issuer\'s URL address of the certificates') p.add_argument('-n', '--issuer_name', type=str, help='the issuer\'s name') p.add_argument('-e', '--issuer_email', type=str, help='the issuer\'s email') p.add_argument('-m', '--issuer_logo_file', type=str, help='the issuer\' logo image') p.add_argument('-o', '--output_file', type=str, help='the output file to save the issuer\'s identification file') args, _ = p.parse_known_args() return args
def get_config(): base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) p = configargparse.getArgumentParser(default_config_files=[os.path.join(base_dir, 'conf.ini')]) p.add('-c', '--my-config', required=False, is_config_file=True, help='config file path') p.add_argument('-k', '--extended_public_key', type=str, required=True, help='the HD extended public key used to generate the revocation addresses') p.add_argument('-p', '--key_path', type=str, help='the key path used to derive the child key under which the addresses will be generated') p.add_argument('-n', '--number_of_addresses', type=int, default=10, help='the number of revocation addresses to generate') p.add_argument('-o', '--output_file', type=str, help='the output file to save the revocation addresses') p.add_argument('-u', '--use_uncompressed', action='store_true', default=False, help='whether to use uncompressed bitcoin addresses') args, _ = p.parse_known_args() return args
def csvimport_main(): print('pynYNAB CSV import') """Manually import a CSV into a nYNAB budget""" parser = configargparse.getArgumentParser('pynYNAB') parser.description=inspect.getdoc(csvimport_main) parser.add_argument('csvfile', metavar='CSVpath', type=str, help='The CSV file to import') parser.add_argument('schema', metavar='schemaName', type=str, help='The CSV schema to use (see csv_schemas directory)') parser.add_argument('accountname', metavar='AccountName', type=str,nargs='?', help='The nYNAB account name to use') parser.add_argument('-import-duplicates', action='store_true', help='Forces the import even if a duplicate (same date, account, amount, memo, payee) is found') args = parser.parse_args() test_common_args(args) if not os.path.exists(args.csvfile): get_logger().error('input CSV file does not exist') exit(-1) do_csvimport(args)
def get_config(): cwd = os.getcwd() p = configargparse.getArgumentParser(default_config_files=[os.path.join(cwd, 'conf.ini')]) p.add('-c', '--my-config', required=False, is_config_file=True, help='config file path') p.add_argument('--data_dir', type=str, help='where data files are located') p.add_argument('--issuer_logo_file', type=str, help='issuer logo image file, png format') p.add_argument('--issuer_signature_file', type=str, help='issuer signature image file, png format') p.add_argument('--cert_image_file', type=str, help='issuer logo image file, png format') p.add_argument('--issuer_url', type=str, help='issuer URL') p.add_argument('--issuer_certs_url', type=str, help='issuer certificates URL') p.add_argument('--issuer_email', type=str, help='issuer email') p.add_argument('--issuer_name', type=str, help='issuer name') p.add_argument('--issuer_id', type=str, help='path to issuer public keys') p.add_argument('--certificate_language', type=str, required=False, help='certificate language') p.add_argument('--certificate_description', type=str, help='the display description of the certificate') p.add_argument('--certificate_title', type=str, help='the title of the certificate') p.add_argument('--template_dir', type=str, help='the template output directory') p.add_argument('--template_file_name', type=str, help='the template file name') p.add_argument('--hash_emails', action='store_true', help='whether to hash emails in the certificate') p.add_argument('--additional_global_fields', action=helpers.make_action('global_fields'), help='additional global fields') p.add_argument('--additional_per_recipient_fields', action=helpers.make_action('per_recipient_fields'), help='additional per-recipient fields') args, _ = p.parse_known_args() args.abs_data_dir = os.path.abspath(os.path.join(cwd, args.data_dir)) return args
def get_config(): cwd = os.getcwd() config_file_path = os.path.join(cwd, 'conf.ini') p = configargparse.getArgumentParser(default_config_files=[config_file_path]) p.add('-c', '--my-config', required=False, is_config_file=True, help='config file path') p.add_argument('--data_dir', type=str, help='where data files are located') p.add_argument('--issuer_logo_file', type=str, help='issuer logo image file, png format') p.add_argument('--cert_image_file', type=str, help='issuer logo image file, png format') p.add_argument('--issuer_url', type=str, help='issuer URL') p.add_argument('--issuer_certs_url', type=str, help='issuer certificates URL') p.add_argument('--issuer_email', required=True, type=str, help='issuer email') p.add_argument('--issuer_name', required=True, type=str, help='issuer name') p.add_argument('--issuer_id', required=True, type=str, help='issuer profile') p.add_argument('--issuer_key', type=str, help='issuer issuing key') p.add_argument('--certificate_description', type=str, help='the display description of the certificate') p.add_argument('--certificate_title', required=True, type=str, help='the title of the certificate') p.add_argument('--criteria_narrative', required=True, type=str, help='criteria narrative') p.add_argument('--template_dir', type=str, help='the template output directory') p.add_argument('--template_file_name', type=str, help='the template file name') p.add_argument('--hash_emails', action='store_true', help='whether to hash emails in the certificate') p.add_argument('--revocation_list', type=str, help='issuer revocation list') p.add_argument('--issuer_public_key', type=str, help='issuer public key') p.add_argument('--badge_id', required=True, type=str, help='badge id') p.add_argument('--issuer_signature_lines', action=helpers.make_action('issuer_signature_lines'), help='issuer signature lines') p.add_argument('--additional_global_fields', action=helpers.make_action('global_fields'), help='additional global fields') p.add_argument('--additional_per_recipient_fields', action=helpers.make_action('per_recipient_fields'), help='additional per-recipient fields') args, _ = p.parse_known_args() args.abs_data_dir = os.path.abspath(os.path.join(cwd, args.data_dir)) return args
def get_config(): base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) p = configargparse.getArgumentParser(default_config_files=[os.path.join(base_dir, 'conf.ini')]) p.add('-c', '--my-config', required=False, is_config_file=True, help='config file path') p.add_argument('-p', '--cert_path', type=str, required=True, help='Path to certificates') p.add_argument('-u', '--url_prefix', type=str, help='URL prefix') p.add_argument('-o', '--output_path', type=str, help='Path to output file') args, _ = p.parse_known_args() return args
def get_config(): configure_logger() p = configargparse.getArgumentParser(default_config_files=[os.path.join(PATH, 'conf.ini'), '/etc/cert-issuer/conf.ini']) add_arguments(p) parsed_config, _ = p.parse_known_args() if not parsed_config.safe_mode: logging.warning('Your app is configured to skip the wifi check when the USB is plugged in. Read the ' 'documentation to ensure this is what you want, since this is less secure') # overwrite with enum parsed_config.chain = Chain.parse_from_chain(parsed_config.chain) # ensure it's a supported chain if parsed_config.chain.blockchain_type != BlockchainType.bitcoin and \ parsed_config.chain.blockchain_type != BlockchainType.ethereum and \ parsed_config.chain.blockchain_type != BlockchainType.mock: raise UnknownChainError(parsed_config.chain.name) logging.info('This run will try to issue on the %s chain', parsed_config.chain.name) if parsed_config.chain.blockchain_type == BlockchainType.bitcoin: bitcoin_chain_for_python_bitcoinlib = parsed_config.chain if parsed_config.chain == Chain.bitcoin_regtest: bitcoin_chain_for_python_bitcoinlib = Chain.bitcoin_regtest bitcoin.SelectParams(chain_to_bitcoin_network(bitcoin_chain_for_python_bitcoinlib)) configure_logger() return parsed_config
def create_config(): p = configargparse.getArgumentParser(default_config_files=[os.path.join(BASE_DIR, 'conf_test.ini'), os.path.join(BASE_DIR, 'conf_local.ini'), os.path.join(BASE_DIR, 'conf.ini'), '/etc/cert-issuer/conf.ini']) p.add('-c', '--my-config', required=False, is_config_file=True, help='config file path') p.add_argument('--mongodb_uri', default='mongodb://localhost:27017/test', type=str, env_var='MONGODB_URI', help='Mongo connection string, including db containing certificates') p.add_argument('--cert_store_type', type=str, help='type of key value store to use for Cert Store') p.add_argument('--cert_store_path', type=str, help='path to file system Cert Store') p.add_argument('--v1_aware', action='store_true', help='Whether to support v1 certs') args, _ = p.parse_known_args() return args
def ofximport_main(): print('pynYNAB OFX import') """Manually import an OFX into a nYNAB budget""" parser = configargparse.getArgumentParser('pynYNAB') parser.description = inspect.getdoc(ofximport_main) parser.add_argument('ofxfile', metavar='OFXPath', type=str, help='The OFX file to import') args = parser.parse_args() test_common_args(args) do_ofximport(args)
def get_arg_parser(): """Create the parser for the command-line args.""" parser = configargparse.getArgumentParser() parser.add_argument("--longhelp", help="Print out configuration details", action="store_true") parser.add_argument("--marathon", "-m", nargs="+", env_var='MARATHON_URL', help="[required] Marathon endpoint, eg. -m " + "http://marathon1:8080 http://marathon2:8080") parser.add_argument("--hostname", env_var='F5_CC_BIGIP_HOSTNAME', help="F5 BIG-IP hostname") parser.add_argument("--username", env_var='F5_CC_BIGIP_USERNAME', help="F5 BIG-IP username") parser.add_argument("--password", env_var='F5_CC_BIGIP_PASSWORD', help="F5 BIG-IP password") parser.add_argument("--partition", env_var='F5_CC_PARTITIONS', help="[required] Only generate config for apps which" " match the specified partition." " Can use this arg multiple times to" " specify multiple partitions", action="append", default=list()) parser.add_argument("--health-check", "-H", env_var='F5_CC_USE_HEALTHCHECK', help="If set, respect Marathon's health check " "statuses before adding the app instance into " "the backend pool.", action="store_true") parser.add_argument("--marathon-ca-cert", env_var='F5_CC_MARATHON_CA_CERT', help="CA certificate for Marathon HTTPS connections") parser.add_argument('--sse-timeout', "-t", type=int, env_var='F5_CC_SSE_TIMEOUT', default=30, help='Marathon event stream timeout') parser.add_argument('--verify-interval', "-v", type=int, env_var='F5_CC_VERIFY_INTERVAL', default=30, help="Interval at which to verify " "the BIG-IP configuration.") parser.add_argument("--version", help="Print out version information and exit", action="store_true") parser = set_logging_args(parser) parser = set_marathon_auth_args(parser) return parser