当前位置: 首页>>代码示例>>Python>>正文


Python optparse.Values方法代码示例

本文整理汇总了Python中optparse.Values方法的典型用法代码示例。如果您正苦于以下问题:Python optparse.Values方法的具体用法?Python optparse.Values怎么用?Python optparse.Values使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在optparse的用法示例。


在下文中一共展示了optparse.Values方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_default_values

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Values [as 别名]
def get_default_values(self):
        """Overriding to make updating the defaults after instantiation of
        the option parser possible, _update_defaults() does the dirty work."""
        if not self.process_default_values:
            # Old, pre-Optik 1.5 behaviour.
            return optparse.Values(self.defaults)

        # Load the configuration, or error out in case of an error
        try:
            self.config.load()
        except ConfigurationError as err:
            self.exit(2, err.args[0])

        defaults = self._update_defaults(self.defaults.copy())  # ours
        for option in self._get_all_options():
            default = defaults.get(option.dest)
            if isinstance(default, string_types):
                opt_str = option.get_opt_string()
                defaults[option.dest] = option.check_value(opt_str, default)
        return optparse.Values(defaults) 
开发者ID:HaoZhang95,项目名称:Python24,代码行数:22,代码来源:baseparser.py

示例2: get_config_file_settings

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Values [as 别名]
def get_config_file_settings(self, config_file):
        """Returns a dictionary containing appropriate config file settings."""
        parser = ConfigParser()
        parser.read(config_file, self)
        self.config_files.extend(parser._files)
        base_path = os.path.dirname(config_file)
        applied = {}
        settings = Values()
        for component in self.components:
            if not component:
                continue
            for section in (tuple(component.config_section_dependencies or ())
                            + (component.config_section,)):
                if section in applied:
                    continue
                applied[section] = 1
                settings.update(parser.get_section(section), self)
        make_paths_absolute(
            settings.__dict__, self.relative_path_settings, base_path)
        return settings.__dict__ 
开发者ID:skarlekar,项目名称:faces,代码行数:22,代码来源:frontend.py

示例3: check_install_build_global

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Values [as 别名]
def check_install_build_global(options, check_options=None):
    # type: (Values, Optional[Values]) -> None
    """Disable wheels if per-setup.py call options are set.

    :param options: The OptionParser options to update.
    :param check_options: The options to check, if not supplied defaults to
        options.
    """
    if check_options is None:
        check_options = options

    def getname(n):
        return getattr(check_options, n, None)
    names = ["build_options", "global_options", "install_options"]
    if any(map(getname, names)):
        control = options.format_control
        control.disallow_binaries()
        warnings.warn(
            'Disabling all use of wheels due to the use of --build-options '
            '/ --global-options / --install-options.', stacklevel=2,
        ) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:23,代码来源:cmdoptions.py

示例4: get_default_values

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Values [as 别名]
def get_default_values(self):
        """Overriding to make updating the defaults after instantiation of
        the option parser possible, _update_defaults() does the dirty work."""
        if not self.process_default_values:
            # Old, pre-Optik 1.5 behaviour.
            return optparse.Values(self.defaults)

        # Load the configuration, or error out in case of an error
        try:
            self.config.load()
        except ConfigurationError as err:
            self.exit(UNKNOWN_ERROR, str(err))

        defaults = self._update_defaults(self.defaults.copy())  # ours
        for option in self._get_all_options():
            default = defaults.get(option.dest)
            if isinstance(default, string_types):
                opt_str = option.get_opt_string()
                defaults[option.dest] = option.check_value(opt_str, default)
        return optparse.Values(defaults) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:22,代码来源:parser.py

示例5: __init__

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Values [as 别名]
def __init__(
        self,
        filename,  # type: str
        lineno,  # type: int
        comes_from,  # type: str
        args,  # type: str
        opts,  # type: Values
        constraint,  # type: bool
    ):
        # type: (...) -> None
        self.filename = filename
        self.lineno = lineno
        self.comes_from = comes_from
        self.args = args
        self.opts = opts
        self.constraint = constraint 
开发者ID:pantsbuild,项目名称:pex,代码行数:18,代码来源:req_file.py

示例6: check_install_build_global

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Values [as 别名]
def check_install_build_global(options, check_options=None):
    # type: (Values, Optional[Values]) -> None
    """Disable wheels if per-setup.py call options are set.

    :param options: The OptionParser options to update.
    :param check_options: The options to check, if not supplied defaults to
        options.
    """
    if check_options is None:
        check_options = options

    def getname(n):
        # type: (str) -> Optional[Any]
        return getattr(check_options, n, None)
    names = ["build_options", "global_options", "install_options"]
    if any(map(getname, names)):
        control = options.format_control
        control.disallow_binaries()
        warnings.warn(
            'Disabling all use of wheels due to the use of --build-option '
            '/ --global-option / --install-option.', stacklevel=2,
        ) 
开发者ID:pantsbuild,项目名称:pex,代码行数:24,代码来源:cmdoptions.py

示例7: handle_pip_version_check

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Values [as 别名]
def handle_pip_version_check(self, options):
        # type: (Values) -> None
        """
        Do the pip version check if not disabled.

        This overrides the default behavior of not doing the check.
        """
        # Make sure the index_group options are present.
        assert hasattr(options, 'no_index')

        if options.disable_pip_version_check or options.no_index:
            return

        # Otherwise, check if we're using the latest version of pip available.
        session = self._build_session(
            options,
            retries=0,
            timeout=min(5, options.timeout)
        )
        with session:
            pip_self_version_check(session, options) 
开发者ID:pantsbuild,项目名称:pex,代码行数:23,代码来源:req_command.py

示例8: __init__

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Values [as 别名]
def __init__(self):
        self.config = optparse.Values()
        self.load_defaults() 
开发者ID:AtomLinter,项目名称:linter-pylama,代码行数:5,代码来源:config.py

示例9: get_default_values

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Values [as 别名]
def get_default_values(self):
        """Overriding to make updating the defaults after instantiation of
        the option parser possible, _update_defaults() does the dirty work."""
        if not self.process_default_values:
            # Old, pre-Optik 1.5 behaviour.
            return optparse.Values(self.defaults)

        defaults = self._update_defaults(self.defaults.copy())  # ours
        for option in self._get_all_options():
            default = defaults.get(option.dest)
            if isinstance(default, string_types):
                opt_str = option.get_opt_string()
                defaults[option.dest] = option.check_value(opt_str, default)
        return optparse.Values(defaults) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:16,代码来源:baseparser.py

示例10: get_default_values

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Values [as 别名]
def get_default_values(self):
        """Overridding to make updating the defaults after instantiation of
        the option parser possible, _update_defaults() does the dirty work."""
        if not self.process_default_values:
            # Old, pre-Optik 1.5 behaviour.
            return optparse.Values(self.defaults)

        defaults = self._update_defaults(self.defaults.copy())  # ours
        for option in self._get_all_options():
            default = defaults.get(option.dest)
            if isinstance(default, string_types):
                opt_str = option.get_opt_string()
                defaults[option.dest] = option.check_value(opt_str, default)
        return optparse.Values(defaults) 
开发者ID:jpush,项目名称:jbox,代码行数:16,代码来源:baseparser.py

示例11: _update_defaults

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Values [as 别名]
def _update_defaults(self, defaults):
        """Updates the given defaults with values from the config files and
        the environ. Does a little special handling for certain types of
        options (lists)."""

        # Accumulate complex default state.
        self.values = optparse.Values(self.defaults)
        late_eval = set()
        # Then set the options with those values
        for key, val in self._get_ordered_configuration_items():
            # '--' because configuration supports only long names
            option = self.get_option('--' + key)

            # Ignore options not present in this parser. E.g. non-globals put
            # in [global] by users that want them to apply to all applicable
            # commands.
            if option is None:
                continue

            if option.action in ('store_true', 'store_false', 'count'):
                val = strtobool(val)
            elif option.action == 'append':
                val = val.split()
                val = [self.check_default(option, key, v) for v in val]
            elif option.action == 'callback':
                late_eval.add(option.dest)
                opt_str = option.get_opt_string()
                val = option.convert_value(opt_str, val)
                # From take_action
                args = option.callback_args or ()
                kwargs = option.callback_kwargs or {}
                option.callback(option, opt_str, val, self, *args, **kwargs)
            else:
                val = self.check_default(option, key, val)

            defaults[option.dest] = val

        for key in late_eval:
            defaults[key] = getattr(self.values, key)
        self.values = None
        return defaults 
开发者ID:HaoZhang95,项目名称:Python24,代码行数:43,代码来源:baseparser.py

示例12: __init__

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Values [as 别名]
def __init__(self, *args, **kwargs):
        optparse.Values.__init__(self, *args, **kwargs)
        if (not hasattr(self, 'record_dependencies')
            or self.record_dependencies is None):
            # Set up dependency list, in case it is needed.
            self.record_dependencies = docutils.utils.DependencyList() 
开发者ID:skarlekar,项目名称:faces,代码行数:8,代码来源:frontend.py

示例13: update

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Values [as 别名]
def update(self, other_dict, option_parser):
        if isinstance(other_dict, Values):
            other_dict = other_dict.__dict__
        other_dict = other_dict.copy()
        for setting in list(option_parser.lists.keys()):
            if (hasattr(self, setting) and setting in other_dict):
                value = getattr(self, setting)
                if value:
                    value += other_dict[setting]
                    del other_dict[setting]
        self._update_loose(other_dict) 
开发者ID:skarlekar,项目名称:faces,代码行数:13,代码来源:frontend.py

示例14: get_standard_config_settings

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Values [as 别名]
def get_standard_config_settings(self):
        settings = Values()
        for filename in self.get_standard_config_files():
            settings.update(self.get_config_file_settings(filename), self)
        return settings 
开发者ID:skarlekar,项目名称:faces,代码行数:7,代码来源:frontend.py

示例15: get_default_values

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import Values [as 别名]
def get_default_values(self):
        """Needed to get custom `Values` instances."""
        defaults = Values(self.defaults)
        defaults._config_files = self.config_files
        return defaults 
开发者ID:skarlekar,项目名称:faces,代码行数:7,代码来源:frontend.py


注:本文中的optparse.Values方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。