當前位置: 首頁>>代碼示例>>Python>>正文


Python configparser.SectionProxy方法代碼示例

本文整理匯總了Python中configparser.SectionProxy方法的典型用法代碼示例。如果您正苦於以下問題:Python configparser.SectionProxy方法的具體用法?Python configparser.SectionProxy怎麽用?Python configparser.SectionProxy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在configparser的用法示例。


在下文中一共展示了configparser.SectionProxy方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: 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

示例2: 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

示例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;未經允許,請勿轉載。