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


Python configparser.SectionProxy方法代码示例

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


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

示例1: initialize_plugin

# 需要导入模块: import configparser [as 别名]
# 或者: from configparser import SectionProxy [as 别名]
def initialize_plugin(self) -> None:
        """
        Initialize the plugin reading patterns from the config.
        """
        try:
            config: SectionProxy = self.configuration[self.name]
        except KeyError:
            return
        else:
            logger.info(f"Initializing {self.name} plugin")
            if not self.initilized:
                for k in config:
                    pattern_strings = [
                        pattern for pattern in config[k].split("\n") if pattern
                    ]
                    self.patterns[k] = [
                        re.compile(pattern_string) for pattern_string in pattern_strings
                    ]
                logger.info(f"Initialized {self.name} plugin with {self.patterns}")
                self.initilized = True 
开发者ID:pypa,项目名称:bandersnatch,代码行数:22,代码来源:metadata_filter.py

示例2: collect_init_args

# 需要导入模块: import configparser [as 别名]
# 或者: from configparser import SectionProxy [as 别名]
def collect_init_args(cls, config: configparser.SectionProxy) -> Dict[str, Any]:
        from lxml.etree import XPath, XPathSyntaxError  # noqa: S410 our input

        try:
            args = NetworkMixin.collect_init_args(config)
            args["xpath"] = config["xpath"].strip()
            # validate the expression
            try:
                XPath(args["xpath"])
            except XPathSyntaxError as error:
                raise ConfigurationError(
                    "Invalid xpath expression: " + args["xpath"]
                ) from error
            return args
        except KeyError as error:
            raise ConfigurationError("Lacks " + str(error) + " config entry") from error 
开发者ID:languitar,项目名称:autosuspend,代码行数:18,代码来源:util.py

示例3: create

# 需要导入模块: import configparser [as 别名]
# 或者: from configparser import SectionProxy [as 别名]
def create(
        cls, name: str, config: configparser.SectionProxy,
    ) -> "NetworkBandwidth":
        try:
            interfaces = config["interfaces"].split(",")
            interfaces = [i.strip() for i in interfaces if i.strip()]
            if not interfaces:
                raise ConfigurationError("No interfaces configured")
            host_interfaces = psutil.net_if_addrs().keys()
            for interface in interfaces:
                if interface not in host_interfaces:
                    raise ConfigurationError(
                        "Network interface {} does not exist".format(interface)
                    )
            threshold_send = config.getfloat("threshold_send", fallback=100)
            threshold_receive = config.getfloat("threshold_receive", fallback=100)
            return cls(name, interfaces, threshold_send, threshold_receive)
        except KeyError as error:
            raise ConfigurationError(
                "Missing configuration key: {}".format(error)
            ) from error
        except ValueError as error:
            raise ConfigurationError(
                "Threshold in wrong format: {}".format(error)
            ) from error 
开发者ID:languitar,项目名称:autosuspend,代码行数:27,代码来源:activity.py

示例4: read_ini_config

# 需要导入模块: import configparser [as 别名]
# 或者: from configparser import SectionProxy [as 别名]
def read_ini_config(
    config_path: Path, sections: Optional[List[str]] = None
) -> configparser.SectionProxy:
    """Read a config_path using ConfigParser

    Args:
        config_path: path to the INI config file
        sections: sections of config file to return, default to ['mutatest'] if None

    Returns:
        config section proxy

    Raises:
        KeyError if ``section`` not in ``config_path``.
    """

    sections = sections or ["mutatest"]
    config = configparser.ConfigParser()
    # ensures [  mutatest  ] is valid like [mutatest] in a section key
    config.SECTCRE = re.compile(r"\[ *(?P<header>[^]]+?) *\]")  # type: ignore

    config.read(config_path)

    # Attempt sections in the list, if none are matched raise a KeyError
    for section in sections:
        try:
            return config[section]
        except KeyError:
            continue

    raise KeyError 
开发者ID:EvanKepner,项目名称:mutatest,代码行数:33,代码来源:cli.py

示例5: test_get_config

# 需要导入模块: import configparser [as 别名]
# 或者: from configparser import SectionProxy [as 别名]
def test_get_config(self):
        self.assertIsInstance(self.config.get_config(),
                              configparser.SectionProxy) 
开发者ID:gabfl,项目名称:vault,代码行数:5,代码来源:test_Config.py

示例6: __init__

# 需要导入模块: import configparser [as 别名]
# 或者: from configparser import SectionProxy [as 别名]
def __init__(self, section: SectionProxy):
        # 是否启用发音
        self.enabled = section.getboolean('enabled')
        # 是否自动播放发音
        self.auto_play = section.getboolean('auto_play')
        # 发音客户端 id
        self.client_id = section.get('client')

        if self.enabled and not self.client_id:
            raise ConfigError('No speech client specified')


# 各发音客户端配置基类 
开发者ID:bianjp,项目名称:popup-dict,代码行数:15,代码来源:base.py

示例7: __init__

# 需要导入模块: import configparser [as 别名]
# 或者: from configparser import SectionProxy [as 别名]
def __init__(self, section: SectionProxy):
        self.client_id = section.get('client')

        if not self.client_id:
            raise ConfigError('No query client specified')


# 查询客户端基本配置 
开发者ID:bianjp,项目名称:popup-dict,代码行数:10,代码来源:base.py

示例8: __init__

# 需要导入模块: import configparser [as 别名]
# 或者: from configparser import SectionProxy [as 别名]
def __init__(self, model_name: str, config_section: SectionProxy):
        super(Word2VecAnalyzer, self).__init__("word2vec", model_name, config_section) 
开发者ID:NVISO-BE,项目名称:ee-outliers,代码行数:4,代码来源:word2vec.py

示例9: configure

# 需要导入模块: import configparser [as 别名]
# 或者: from configparser import SectionProxy [as 别名]
def configure(self, config: configparser.SectionProxy) -> None:
        """
        Configure the extractor from the mapping section.

        Args:
            config:
                configuration section for the entry
        """
        pass 
开发者ID:languitar,项目名称:pass-git-helper,代码行数:11,代码来源:passgithelper.py

示例10: __init__

# 需要导入模块: import configparser [as 别名]
# 或者: from configparser import SectionProxy [as 别名]
def __init__(self, section: configparser.SectionProxy, key: str) -> None:
        self.section = section
        self.key = key
        self.value = self.section.get(key) 
开发者ID:actionless,项目名称:pikaur,代码行数:6,代码来源:config.py

示例11: create

# 需要导入模块: import configparser [as 别名]
# 或者: from configparser import SectionProxy [as 别名]
def create(cls, name: str, config: configparser.SectionProxy) -> Check:
        try:
            return cls(name, config["command"].strip())  # type: ignore
        except KeyError as error:
            raise ConfigurationError("Missing command specification") from error 
开发者ID:languitar,项目名称:autosuspend,代码行数:7,代码来源:util.py

示例12: _add_default_kodi_url

# 需要导入模块: import configparser [as 别名]
# 或者: from configparser import SectionProxy [as 别名]
def _add_default_kodi_url(config: configparser.SectionProxy) -> None:
    if "url" not in config:
        config["url"] = "http://localhost:8080/jsonrpc" 
开发者ID:languitar,项目名称:autosuspend,代码行数:5,代码来源:activity.py

示例13: collect_init_args

# 需要导入模块: import configparser [as 别名]
# 或者: from configparser import SectionProxy [as 别名]
def collect_init_args(cls, config: configparser.SectionProxy) -> Dict[str, Any]:
        try:
            _add_default_kodi_url(config)
            args = NetworkMixin.collect_init_args(config)
            args["suspend_while_paused"] = config.getboolean(
                "suspend_while_paused", fallback=False
            )
            return args
        except ValueError as error:
            raise ConfigurationError("Configuration error {}".format(error)) from error 
开发者ID:languitar,项目名称:autosuspend,代码行数:12,代码来源:activity.py


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