How to use the configargparse.SUPPRESS function in ConfigArgParse

To help you get started, we’ve selected a few ConfigArgParse examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github curzon01 / mqtt2sql / mqtt2sql.py View on Github external
mqtt_group.add_argument('--keyfile', dest='mqtt_keyfile', help=configargparse.SUPPRESS)
    mqtt_group.add_argument(
        '--mqtt-insecure',
        dest='mqtt_insecure',
        action='store_true',
        default=DEFAULTS['mqtt-insecure'],
        help="suppress TLS verification (default {})".format(DEFAULTS['mqtt-insecure']) if MODULE_SSL_AVAIL else configargparse.SUPPRESS)
    mqtt_group.add_argument('--insecure', dest='mqtt_insecure', help=configargparse.SUPPRESS)
    mqtt_group.add_argument(
        '--mqtt-keepalive',
        metavar='',
        dest='mqtt_keepalive',
        type=int,
        default=DEFAULTS['mqtt-keepalive'],
        help="keepalive timeout for the client (default {})".format(DEFAULTS['mqtt-keepalive']))
    mqtt_group.add_argument('--keepalive', dest='mqtt_keepalive', type=int, help=configargparse.SUPPRESS)

    sql_group = parser.add_argument_group('SQL Options')
    sql_choices = []
    if MODULE_MYSQLDB_AVAIL:
        sql_choices.append('mysql')
    if MODULE_SQLITE3_AVAIL:
        sql_choices.append('sqlite')
    if len(sql_choices) == 0:
        SignalHandler.exitus(ExitCode.MISSING_MODULE, 'Either module MySQLdb or sqlite must be installed')

    sql_group.add_argument(
        '--sql-type',
        metavar='',
        dest='sql_type',
        choices=sql_choices,
        default=DEFAULTS['sql-type'],
github danielhers / tupa / tupa / config.py View on Github external
def __init__(self, name=None, *args, **kwargs):
        """
        :param name: name of hyperparams subset
        :param args: raw arg strings
        :param kwargs: parsed and initialized values
        """
        self.name = name
        self.str_args = list(args) + ["--%s %s" % (k.replace("_", "-"), v) for k, v in kwargs.items()]
        self.args = vars(add_param_arguments(arg_default=SUPPRESS).parse_args(args))
        self.args.update(kwargs)
github theotherp / nzbhydra / nzbhydra.py View on Github external
logger.info("Database shut down")

if __name__ == '__main__':

    parser = configargparse.ArgParser(description='NZBHydra')
    parser.add_argument('--config', action='store', env_var="hydra_config", help='Settings file to load. Can also be set using the environment variable "hydra_config"', default="settings.cfg")
    parser.add_argument('--database', action='store', env_var="hydra_database", help='Database file to load. Can also be set using the environment variable "hydra_database"', default="nzbhydra.db")
    parser.add_argument('--logfile', action='store', help='Log file. If set overwrites config value', default=None)
    parser.add_argument('--host', '-H', action='store', env_var="hydra_host", help='Host to run on. Can also be set using the environment variable "hydra_host"')
    parser.add_argument('--port', '-p', action='store', env_var="hydra_port", help='Port to run on. Can also be set using the environment variable "hydra_port"', type=int)
    parser.add_argument('--urlbase', '-u', action='store', env_var="hydra_urlbase", help='URL base (e.g. "/nzbhydra"). Can also be set using the environment variable "hydra_urlbase"', default=None)
    parser.add_argument('--nobrowser', action='store_true', env_var="hydra_nobrowser", help='Don\'t open URL on startup', default=False)
    parser.add_argument('--daemon', '-D', action='store_true', help='Run as daemon. *nix only', default=False)
    parser.add_argument('--pidfile', action='store', help='PID file. Only relevant with daemon argument', default="nzbhydra.pid")
    parser.add_argument('--quiet', '-q', action='store_true', help='Quiet (no output)', default=False)
    parser.add_argument('--restarted', action='store_true', help=configargparse.SUPPRESS, default=False)
    parser.add_argument('--clearloganddb', action='store_true', help=configargparse.SUPPRESS, default=False)
    parser.add_argument('--socksproxy', action='store', help='SOCKS proxy to use in format socks5://user:pass@host:port', default=None)

    args, unknown = parser.parse_known_args()

    if args.quiet:
        log.quiet_output()
    with open("version.txt") as f:
        version = f.read()
    logger.notice("Starting NZBHydra %s" % version)
    logger.notice("Base path is {}".format(basepath))

    run(args)
    if "RESTART" in os.environ.keys() and os.environ["RESTART"] == "1":
        if "STARTEDBYTRAYHELPER" in os.environ.keys():
            # We don't restart ourself but use a special return code so we are restarted by the tray tool
github arendst / Tasmota / tools / decode-config.py View on Github external
jsonformat.add_argument('--json-raw-values',
                            dest='jsonrawvalues',
                            action='store_true',
                            default=DEFAULTS['jsonformat']['jsonrawvalues'],
                            help=configargparse.SUPPRESS) #"output raw values{}".format(' (default)' if DEFAULTS['jsonformat']['jsonrawvalues'] else '') )
    jsonformat.add_argument('--json-convert-values',
                            dest='jsonrawvalues',
                            action='store_false',
                            default=DEFAULTS['jsonformat']['jsonrawvalues'],
                            help=configargparse.SUPPRESS) #"output converted, human readable values{}".format(' (default)' if not DEFAULTS['jsonformat']['jsonrawvalues'] else '') )

    jsonformat.add_argument('--json-raw-keys',
                            dest='jsonrawkeys',
                            action='store_true',
                            default=DEFAULTS['jsonformat']['jsonrawkeys'],
                            help=configargparse.SUPPRESS) #"output bitfield raw keys{}".format(' (default)' if DEFAULTS['jsonformat']['jsonrawkeys'] else '') )
    jsonformat.add_argument('--json-no-raw-keys',
                            dest='jsonrawkeys',
                            action='store_false',
                            default=DEFAULTS['jsonformat']['jsonrawkeys'],
                            help=configargparse.SUPPRESS) #"do not output bitfield raw keys{}".format(' (default)' if not DEFAULTS['jsonformat']['jsonrawkeys'] else '') )

    jsonformat.add_argument('--json-hide-pw',
                            dest='jsonhidepw',
                            action='store_true',
                            default=DEFAULTS['jsonformat']['jsonhidepw'],
                            help="hide passwords{}".format(' (default)' if DEFAULTS['jsonformat']['jsonhidepw'] else '') )
    jsonformat.add_argument('--json-unhide-pw',
                            dest='jsonhidepw',
                            action='store_false',
                            default=DEFAULTS['jsonformat']['jsonhidepw'],
                            help="unhide passwords{}".format(' (default)' if not DEFAULTS['jsonformat']['jsonhidepw'] else '') )
github aajanki / yle-dl / yledl / yledl.py View on Github external
action_group.add_argument('--showurl', action='store_true',
                              help="Print URL, don't download")
    action_group.add_argument('--showtitle', action='store_true',
                              help="Print stream title, don't download")
    action_group.add_argument('--showepisodepage', action='store_true',
                              help='Print web page for each episode')
    action_group.add_argument('--showmetadata', action='store_true',
                              help='Print metadata about available streams')
    io_group.add_argument('--vfat', action='store_true',
                          help='Output Windows-compatible filenames')
    resume_group = io_group.add_mutually_exclusive_group()
    # --resume is the new default, the option is still accepted but
    # doesn't do anything
    resume_group.add_argument('--resume', action='store_true',
                              dest='resume', default=True,
                              help=configargparse.SUPPRESS)
    resume_group.add_argument('--no-resume', action='store_false',
                              dest='resume',
                              help='Don\'t resume partial files, '
                              'download the whole stream again')
    io_group.add_argument('--no-overwrite', action='store_false',
                          dest='overwrite',
                          help='Quit if a file already exists')
    io_group.add_argument('--ratelimit', metavar='BR', type=int,
                          help='Maximum bandwidth consumption, '
                          'interger in kB/s')
    io_group.add_argument('--proxy', metavar='URI',
                          type=to_unicode,
                          help='HTTP(S) proxy to use. Example: --proxy localhost:8118')
    io_group.add_argument('--postprocess', metavar='CMD',
                          type=to_unicode,
                          help='Execute the command CMD after a successful '
github arendst / Tasmota / tools / decode-config.py View on Github external
jsonformat.add_argument('--json-sort',
                            dest='jsonsort',
                            action='store_true',
                            default=DEFAULTS['jsonformat']['jsonsort'],
                            help=configargparse.SUPPRESS) #"sort json keywords{}".format(' (default)' if DEFAULTS['jsonformat']['jsonsort'] else '') )
    jsonformat.add_argument('--json-unsort',
                            dest='jsonsort',
                            action='store_false',
                            default=DEFAULTS['jsonformat']['jsonsort'],
                            help=configargparse.SUPPRESS) #"do not sort json keywords{}".format(' (default)' if not DEFAULTS['jsonformat']['jsonsort'] else '') )

    jsonformat.add_argument('--json-raw-values',
                            dest='jsonrawvalues',
                            action='store_true',
                            default=DEFAULTS['jsonformat']['jsonrawvalues'],
                            help=configargparse.SUPPRESS) #"output raw values{}".format(' (default)' if DEFAULTS['jsonformat']['jsonrawvalues'] else '') )
    jsonformat.add_argument('--json-convert-values',
                            dest='jsonrawvalues',
                            action='store_false',
                            default=DEFAULTS['jsonformat']['jsonrawvalues'],
                            help=configargparse.SUPPRESS) #"output converted, human readable values{}".format(' (default)' if not DEFAULTS['jsonformat']['jsonrawvalues'] else '') )

    jsonformat.add_argument('--json-raw-keys',
                            dest='jsonrawkeys',
                            action='store_true',
                            default=DEFAULTS['jsonformat']['jsonrawkeys'],
                            help=configargparse.SUPPRESS) #"output bitfield raw keys{}".format(' (default)' if DEFAULTS['jsonformat']['jsonrawkeys'] else '') )
    jsonformat.add_argument('--json-no-raw-keys',
                            dest='jsonrawkeys',
                            action='store_false',
                            default=DEFAULTS['jsonformat']['jsonrawkeys'],
                            help=configargparse.SUPPRESS) #"do not output bitfield raw keys{}".format(' (default)' if not DEFAULTS['jsonformat']['jsonrawkeys'] else '') )
github curzon01 / mqtt2sql / mqtt2sql.py View on Github external
metavar="",
        dest='configfile',
        is_config_file=True,
        default=DEFAULTS['configfile'],
        help="Config file, can be used instead of command parameter (default {})".format(DEFAULTS['configfile'])
    )

    mqtt_group = parser.add_argument_group('MQTT Options')
    mqtt_group.add_argument(
        '--mqtt-host',
        metavar='',
        dest='mqtt_host',
        default=DEFAULTS['mqtt-host'],
        help="host to connect to (default '{}')".format(DEFAULTS['mqtt-host'])
    )
    mqtt_group.add_argument('--mqtthost', '--host', dest='mqtt_host', help=configargparse.SUPPRESS)
    mqtt_group.add_argument(
        '--mqtt-port',
        metavar='',
        dest='mqtt_port',
        type=int,
        default=DEFAULTS['mqtt-port'],
        help="port to connect to (default {})".format(DEFAULTS['mqtt-port'])
    )
    mqtt_group.add_argument('--mqttport', '--port', dest='mqtt_port', type=int, help=configargparse.SUPPRESS)
    mqtt_group.add_argument(
        '--mqtt-username',
        metavar='',
        dest='mqtt_username',
        default=DEFAULTS['mqtt-username'],
        help="username (default {})".format(DEFAULTS['mqtt-username'])
    )
github theotherp / nzbhydra / nzbhydra.py View on Github external
if __name__ == '__main__':

    parser = configargparse.ArgParser(description='NZBHydra')
    parser.add_argument('--config', action='store', env_var="hydra_config", help='Settings file to load. Can also be set using the environment variable "hydra_config"', default="settings.cfg")
    parser.add_argument('--database', action='store', env_var="hydra_database", help='Database file to load. Can also be set using the environment variable "hydra_database"', default="nzbhydra.db")
    parser.add_argument('--logfile', action='store', help='Log file. If set overwrites config value', default=None)
    parser.add_argument('--host', '-H', action='store', env_var="hydra_host", help='Host to run on. Can also be set using the environment variable "hydra_host"')
    parser.add_argument('--port', '-p', action='store', env_var="hydra_port", help='Port to run on. Can also be set using the environment variable "hydra_port"', type=int)
    parser.add_argument('--urlbase', '-u', action='store', env_var="hydra_urlbase", help='URL base (e.g. "/nzbhydra"). Can also be set using the environment variable "hydra_urlbase"', default=None)
    parser.add_argument('--nobrowser', action='store_true', env_var="hydra_nobrowser", help='Don\'t open URL on startup', default=False)
    parser.add_argument('--daemon', '-D', action='store_true', help='Run as daemon. *nix only', default=False)
    parser.add_argument('--pidfile', action='store', help='PID file. Only relevant with daemon argument', default="nzbhydra.pid")
    parser.add_argument('--quiet', '-q', action='store_true', help='Quiet (no output)', default=False)
    parser.add_argument('--restarted', action='store_true', help=configargparse.SUPPRESS, default=False)
    parser.add_argument('--clearloganddb', action='store_true', help=configargparse.SUPPRESS, default=False)
    parser.add_argument('--socksproxy', action='store', help='SOCKS proxy to use in format socks5://user:pass@host:port', default=None)

    args, unknown = parser.parse_known_args()

    if args.quiet:
        log.quiet_output()
    with open("version.txt") as f:
        version = f.read()
    logger.notice("Starting NZBHydra %s" % version)
    logger.notice("Base path is {}".format(basepath))

    run(args)
    if "RESTART" in os.environ.keys() and os.environ["RESTART"] == "1":
        if "STARTEDBYTRAYHELPER" in os.environ.keys():
            # We don't restart ourself but use a special return code so we are restarted by the tray tool
            logger.info("Shutting down so we can be restarted by tray tool")
github danielhers / tupa / tupa / config.py View on Github external
def __init__(self, name=None, *args, **kwargs):
        """
        :param name: name of hyperparams subset
        :param args: raw arg strings
        :param kwargs: parsed and initialized values
        """
        self.name = name
        self.str_args = list(args) + ["--%s %s" % (k.replace("_", "-"), v) for k, v in kwargs.items()]
        self.args = vars(add_param_arguments(arg_default=SUPPRESS).parse_args(args))
        self.args.update(kwargs)