Python configargparse.getArgumentParser() Examples
The following are 16
code examples of configargparse.getArgumentParser().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
configargparse
, or try the search function
.
Example #1
Source File: issue_certificates.py From blockchain-certificates with MIT License | 7 votes |
def load_config(): base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) default_config = os.path.join(base_dir, 'config.ini') p = configargparse.getArgumentParser(default_config_files=[default_config]) p.add('-c', '--config', required=False, is_config_file=True, help='config file path') p.add_argument('-d', '--working_directory', type=str, default='.', help='the main working directory - all paths/files are relative to this') p.add_argument('-s', '--issuer', type=str, help='the name of the institution to (added in certificate metadata)') p.add_argument('-a', '--issuing_address', type=str, help='the issuing address with enough funds for the transaction; assumed to be imported in local node wallet') p.add_argument('-x', '--expiry_date', type=str, help='absolute expiry date up until the certificates will be valid') p.add_argument('-v', '--csv_file', type=str, default='graduates.csv', help='the csv file with the awardees\' data') p.add_argument('-e', '--certificates_directory', type=str, default='certificates', help='the directory where the new certificates will be copied') p.add_argument('-g', '--certificates_global_fields', type=str, default='', help='certificates global fields expressed as JSON strings') p.add_argument('-f', '--cert_names_csv_column', type=str, default='name', help='use this column from csv file for naming the certificates') p.add_argument('-m', '--cert_metadata_columns', type=str, default='', help='the specified columns from the csv or global fields will be included as json metadata') p.add_argument('-n', '--full_node_url', type=str, default='127.0.0.1:18332', help='the url of the full node to use') p.add_argument('-u', '--full_node_rpc_user', type=str, help='the rpc user as specified in the node\'s configuration') p.add_argument('-w', '--full_node_rpc_password', type=str, help='the rpc password as specified in the node\'s configuration') p.add_argument('-t', '--testnet', action='store_true', help='specify if testnet or mainnet will be used') p.add_argument('-f', '--tx_fee_per_byte', type=int, default=100, help='the fee per transaction byte in satoshis') p.add_argument('-p', '--issuer_identifier', type=str, default=' ', help='optional 8 bytes identifier that represents the issuer intented to go on the blockchain') p.add_argument('-r', '--verify_issuer', type=str, default='{ "methods": [] }', help='Which verification methods to use to validate the issuer') args, _ = p.parse_known_args() return args
Example #2
Source File: create_certificates.py From blockchain-certificates with MIT License | 6 votes |
def load_config(): base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) default_config = os.path.join(base_dir, 'config.ini') p = configargparse.getArgumentParser(default_config_files=[default_config]) p.add('-c', '--config', required=False, is_config_file=True, help='config file path') p.add_argument('-d', '--working_directory', type=str, default='.', help='the main working directory - all paths/files are relative to this') p.add_argument('-i', '--pdf_cert_template_file', type=str, default='cert_template.pdf', help='the pdf certificate form to populate') p.add_argument('-s', '--issuer', type=str, help='the name of the institution to (added in certificate metadata)') p.add_argument('-a', '--issuing_address', type=str, help='the issuing address with enough funds for the transaction; assumed to be imported in local node wallet') p.add_argument('-x', '--expiry_date', type=str, help='absolute expiry date up until the certificates will be valid') p.add_argument('-v', '--csv_file', type=str, default='graduates.csv', help='the csv file with the awardees\' data') p.add_argument('-e', '--certificates_directory', type=str, default='certificates', help='the directory where the new certificates will be copied') p.add_argument('-g', '--certificates_global_fields', type=str, default='', help='certificates global fields expressed as JSON string') p.add_argument('-f', '--cert_names_csv_column', type=str, default='name', help='use this column from csv file for naming the certificates') p.add_argument('-m', '--cert_metadata_columns', type=str, default='name,degree,grade', help='the specified columns from the csv or global fields will be included as json metadata') p.add_argument('-n', '--full_node_url', type=str, default='127.0.0.1:18332', help='the url of the full node to use') p.add_argument('-u', '--full_node_rpc_user', type=str, help='the rpc user as specified in the node\'s configuration') p.add_argument('-w', '--full_node_rpc_password', type=str, help='the rpc password as specified in the node\'s configuration') p.add_argument('-t', '--testnet', action='store_true', help='specify if testnet or mainnet will be used') p.add_argument('-f', '--tx_fee_per_byte', type=int, default=100, help='the fee per transaction byte in satoshis') p.add_argument('-p', '--issuer_identifier', type=str, default=' ', help='optional 8 bytes identifier that represents the issuer intented to go on the blockchain') p.add_argument('-r', '--verify_issuer', type=str, default='{ "methods": [] }', help='Which verification methods to use to validate the issuer') args, _ = p.parse_known_args() return args
Example #3
Source File: revoke_certificates.py From blockchain-certificates with MIT License | 6 votes |
def load_config(): base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) default_config = os.path.join(base_dir, 'config.ini') p = configargparse.getArgumentParser( description='Allows to revoke certificates or complete batches or ' 'even future uses of issuing addresses. All revoked ' 'certificates need to be part of the same transaction.', default_config_files=[default_config]) p.add('-c', '--config', required=False, is_config_file=True, help='config file path') group = p.add_mutually_exclusive_group(required='True') group.add_argument('-s', '--address', action='store_true', help='revoke the issuing_address (from config file)') group.add_argument('-b', '--batch', type=str, help='revoke a whole batch identified by its transaction id') group.add_argument('-p', nargs='+', help='a list of certificate pdf files to revoke') p.add_argument('-d', '--working_directory', type=str, default='.', help='the main working directory - all paths/files are relative to this') p.add_argument('-a', '--issuing_address', type=str, help='the issuing address with enough funds for the transaction; assumed to be imported in local node wallet') p.add_argument('-n', '--full_node_url', type=str, default='127.0.0.1:18332', help='the url of the full node to use') p.add_argument('-u', '--full_node_rpc_user', type=str, help='the rpc user as specified in the node\'s configuration') p.add_argument('-w', '--full_node_rpc_password', type=str, help='the rpc password as specified in the node\'s configuration') p.add_argument('-t', '--testnet', action='store_true', help='specify if testnet or mainnet will be used') p.add_argument('-f', '--tx_fee_per_byte', type=int, default=100, help='the fee per transaction byte in satoshis') args, _ = p.parse_known_args() return args
Example #4
Source File: create_v2_issuer.py From cert-tools with MIT License | 6 votes |
def get_config(): cwd = os.getcwd() p = configargparse.getArgumentParser(default_config_files=[os.path.join(cwd, 'conf.ini')]) p.add('-c', '--my-config', required=True, is_config_file=True, help='config file path') p.add_argument('--data_dir', type=str, help='where data files are located') p.add_argument('-k', '--issuer_public_key', type=str, required=True, help='The key(s) an issuer uses to sign Assertions. See https://openbadgespec.org/#Profile for more details') p.add_argument('-k', '--public_key_created', type=str, help='ISO8601-formatted date the issuer public key should be considered active') p.add_argument('-r', '--revocation_list_uri', type=str, required=True, help='URI of the Revocation List used for marking revocation. See https://openbadgespec.org/#Profile for more details') 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 issuer\'s main URL address') 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('-i', '--intro_url', required=False, type=str, help='the issuer\'s introduction URL address') p.add_argument('-o', '--output_file', type=str, help='the output file to save the issuer\'s identification file') args, _ = p.parse_known_args() args.abs_data_dir = os.path.abspath(os.path.join(cwd, args.data_dir)) return args
Example #5
Source File: instantiate_v1_2_certificate_batch.py From cert-tools with MIT License | 6 votes |
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
Example #6
Source File: instantiate_v3_alpha_certificate_batch.py From cert-tools with MIT License | 6 votes |
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('--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('--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
Example #7
Source File: create_issuer.py From cert-tools with MIT License | 6 votes |
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
Example #8
Source File: create_revocation_addresses.py From cert-tools with MIT License | 6 votes |
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
Example #9
Source File: create_v3_alpha_certificate_template.py From cert-tools with MIT License | 6 votes |
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_url', type=str, help='issuer URL') p.add_argument('--issuer_id', required=True, type=str, help='issuer profile') 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('--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
Example #10
Source File: config.py From cert-issuer with MIT License | 5 votes |
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)) global CONFIG CONFIG = parsed_config return parsed_config
Example #11
Source File: publish_hash.py From blockchain-certificates with MIT License | 5 votes |
def load_config(): base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) default_config = os.path.join(base_dir, 'config.ini') p = configargparse.getArgumentParser(default_config_files=[default_config]) p.add('-c', '--config', required=False, is_config_file=True, help='config file path') p.add_argument('-d', '--working_directory', type=str, default='.', help='the main working directory - all paths/files are relative to this') p.add_argument('-a', '--issuing_address', type=str, help='the issuing address with enough funds for the transaction; assumed to be imported in local node wallet') p.add_argument('-n', '--full_node_url', type=str, default='127.0.0.1:18332', help='the url of the full node to use') p.add_argument('-u', '--full_node_rpc_user', type=str, help='the rpc user as specified in the node\'s configuration') p.add_argument('-t', '--testnet', action='store_true', help='specify if testnet or mainnet will be used') p.add_argument('-f', '--tx_fee_per_byte', type=int, default=100, help='the fee per transaction byte in satoshis') args, _ = p.parse_known_args() return args # used primarily for testing
Example #12
Source File: validate_certificates.py From blockchain-certificates with MIT License | 5 votes |
def load_config(): base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) default_config = os.path.join(base_dir, 'config.ini') p = configargparse.getArgumentParser(default_config_files=[default_config]) p.add_argument('-c', '--config', required=False, is_config_file=True, help='config file path') p.add_argument('-t', '--testnet', action='store_true', help='specify if testnet or mainnet will be used') p.add_argument('-u', '--full_node_rpc_user', type=str, help='the rpc user as specified in the node\'s configuration') p.add_argument('-w', '--full_node_rpc_password', type=str, help='the rpc password as specified in the node\'s configuration') p.add_argument('-p', '--issuer_identifier', type=str, help='optional 8 bytes issuer code to be displayed in the blockchain') p.add_argument('-b', '--blockchain_services', type=str, default='{ "services": [ {"blockcypher":{} } ], "required_successes": 1}', help='Which blockchain services to use and the minimum required successes') p.add_argument('-f', nargs='+', help='a list of certificate pdf files to validate') args, _ = p.parse_known_args() return args
Example #13
Source File: create_v1_2_certificate_template.py From cert-tools with MIT License | 5 votes |
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
Example #14
Source File: extract_links.py From cert-tools with MIT License | 5 votes |
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
Example #15
Source File: create_v2_certificate_template.py From cert-tools with MIT License | 5 votes |
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') p.add_argument('--display_html', type=str, help='html content to display') args, _ = p.parse_known_args() args.abs_data_dir = os.path.abspath(os.path.join(cwd, args.data_dir)) return args
Example #16
Source File: test_configargparse.py From ConfigArgParse with MIT License | 5 votes |
def testGlobalInstances(self, name=None): p = configargparse.getArgumentParser(name, prog="prog", usage="test") self.assertEqual(p.usage, "test") self.assertEqual(p.prog, "prog") self.assertRaisesRegex(ValueError, "kwargs besides 'name' can only be " "passed in the first time", configargparse.getArgumentParser, name, prog="prog") p2 = configargparse.getArgumentParser(name) self.assertEqual(p, p2)