terminal.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:piwheels 作者: bennuttall 项目源码 文件源码
def configure_parser(description, log_params=True):
    """
    Configure an argument parser with some common options and return it.
    """
    parser = ArgParser(
        description=description,
        add_config_file_help=False,
        add_env_var_help=False,
        default_config_files=[
            '/etc/piwheels.conf',
            '/usr/local/etc/piwheels.conf',
            '~/.config/piwheels/piwheels.conf'
        ],
        ignore_unknown_config_file_keys=True
    )
    parser.add_argument(
        '--version', action='version', version=__version__)
    parser.add_argument(
        '-c', '--configuration', metavar='FILE', default=None,
        is_config_file=True, help='Specify a configuration file to load')
    if log_params:
        parser.set_defaults(log_level=logging.WARNING)
        parser.add_argument(
            '-q', '--quiet', dest='log_level', action='store_const',
            const=logging.ERROR, help='produce less console output')
        parser.add_argument(
            '-v', '--verbose', dest='log_level', action='store_const',
            const=logging.INFO, help='produce more console output')
        arg = parser.add_argument(
            '-l', '--log-file', metavar='FILE',
            help='log messages to the specified file')
        if argcomplete is not None:
            arg.completer = argcomplete.FilesCompleter(['*.log', '*.txt'])
    return parser
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号