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


Python ConfigParser.get方法代码示例

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


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

示例1: is_secure_option

# 需要导入模块: from configparser import ConfigParser [as 别名]
# 或者: from configparser.ConfigParser import get [as 别名]
def is_secure_option(self, section, option):
        """Test an option to see if it is secured or not.

        :param section: section id
        :type section: string
        :param option: option name
        :type option: string
        :rtype: boolean
        otherwise.
        """
        if not self.has_section(section):
            return False
        if not self.has_option(section, option):
            return False
        if ConfigParser.get(self, section, option) == self._secure_placeholder:
            return True
        return False 
开发者ID:jantman,项目名称:biweeklybudget,代码行数:19,代码来源:config.py

示例2: getstringlist

# 需要导入模块: from configparser import ConfigParser [as 别名]
# 或者: from configparser.ConfigParser import get [as 别名]
def getstringlist(self, section, option):
        "Coerce option to a list of strings or return unchanged if that fails."

        value = ConfigParser.get(self, section, option)

        # This seems to allow for newlines inside values
        # of the config file, but be careful!!
        val = value.replace('\n', '')

        if self.pat.match(val):
            return eval(val)
        else:
            return value


# This class as suggested by /F with an additional hook
# to be able to filter filenames. 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:19,代码来源:testutils.py

示例3: get

# 需要导入模块: from configparser import ConfigParser [as 别名]
# 或者: from configparser.ConfigParser import get [as 别名]
def get(self, section, key=None, **kwargs):  # pylint:disable=arguments-differ
        """ A simple hierachical config access, priority order:
            1. environment var
            2. user config file
            3. bentoml default config file
        """
        if key is None:
            key = section
            section = 'core'
        section = str(section).lower()
        key = str(key).lower()

        env_var = self._env_var_name(section, key)
        if env_var in os.environ:
            return os.environ[env_var]

        if ConfigParser.has_option(self, section, key):
            return ConfigParser.get(self, section, key, **kwargs)
        else:
            raise BentoMLConfigException(
                "section/key '{}/{}' not found in BentoML config".format(section, key)
            ) 
开发者ID:bentoml,项目名称:BentoML,代码行数:24,代码来源:configparser.py

示例4: save

# 需要导入模块: from configparser import ConfigParser [as 别名]
# 或者: from configparser.ConfigParser import get [as 别名]
def save(self, default=False):
        """Save the current or default values into the configuration file.
        """
        LOGGER.info("Generate the configuration file in '%s'", self.filename)

        dirname = osp.dirname(self.filename)
        if not osp.isdir(dirname):
            os.makedirs(dirname)

        with io.open(self.filename, 'w', encoding="utf-8") as fp:
            for section, options in DEFAULT.items():
                fp.write("[{}]\n".format(section))
                for name, value in options.items():
                    if default:
                        val = value[0]
                    else:
                        val = self.get(section, name)
                    fp.write("# {}\n{} = {}\n\n".format(value[1], name, val))

        self.handle_autostart() 
开发者ID:pibooth,项目名称:pibooth,代码行数:22,代码来源:parser.py

示例5: items

# 需要导入模块: from configparser import ConfigParser [as 别名]
# 或者: from configparser.ConfigParser import get [as 别名]
def items(self, section):
        """Get all items for a section. Subclassed, to ensure secure
        items come back with the unencrypted data.

        :param section: section id
        :type section: string
        """
        items = []
        for k, v in ConfigParser.items(self, section):
            if self.is_secure_option(section, k):
                v = self.get(section, k)
            if v == '!!False!!':
                v = False
            items.append((k, v))
        return items 
开发者ID:jantman,项目名称:biweeklybudget,代码行数:17,代码来源:config.py

示例6: set_secure

# 需要导入模块: from configparser import ConfigParser [as 别名]
# 或者: from configparser.ConfigParser import get [as 别名]
def set_secure(self, section, option, value):
        """Set an option and mark it as secure.

        Any subsequent uses of 'set' or 'get' will also
        now know that this option is secure as well.
        """
        if self.keyring_available:
            s_option = "%s%s" % (section, option)
            self._unsaved[s_option] = ('set', value)
            value = self._secure_placeholder
        ConfigParser.set(self, section, option, value) 
开发者ID:jantman,项目名称:biweeklybudget,代码行数:13,代码来源:config.py

示例7: get

# 需要导入模块: from configparser import ConfigParser [as 别名]
# 或者: from configparser.ConfigParser import get [as 别名]
def get(self, section, option, *args):
        """Get option value from section. If an option is secure,
        populates the plain text."""
        if self.is_secure_option(section, option) and self.keyring_available:
            s_option = "%s%s" % (section, option)
            if self._unsaved.get(s_option, [''])[0] == 'set':
                res = self._unsaved[s_option][1]
            else:
                res = keyring.get_password(self.keyring_name, s_option)
        else:
            res = ConfigParser.get(self, section, option, *args)
        if res == '!!False!!':
            return False
        return res 
开发者ID:jantman,项目名称:biweeklybudget,代码行数:16,代码来源:config.py

示例8: encrypt_account

# 需要导入模块: from configparser import ConfigParser [as 别名]
# 或者: from configparser.ConfigParser import get [as 别名]
def encrypt_account(self, id):
        """Make sure that certain fields are encrypted."""
        for key in self.secured_field_names:
            value = self.parser.get(id, key)
            self.parser.set_secure(id, key, value)
        return self 
开发者ID:jantman,项目名称:biweeklybudget,代码行数:8,代码来源:config.py

示例9: printLocation

# 需要导入模块: from configparser import ConfigParser [as 别名]
# 或者: from configparser.ConfigParser import get [as 别名]
def printLocation(depth=1):
    if sys._getframe(depth).f_locals.get('__name__')=='__main__':
        outDir = outputfile('')
        if outDir!=_OUTDIR:
            print('Logs and output files written to folder "%s"' % outDir) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:7,代码来源:testutils.py

示例10: get

# 需要导入模块: from configparser import ConfigParser [as 别名]
# 或者: from configparser.ConfigParser import get [as 别名]
def get(self, section, option, **kwargs):
        """Override the default function of ConfigParser to add a
        default value if section or option is not found.

        :param section: config section name
        :type section: str
        :param option: option name
        :type option: str
        """
        if self.has_section(section) and self.has_option(section, option):
            return ConfigParser.get(self, section, option, **kwargs)
        return str(DEFAULT[section][option][0]) 
开发者ID:pibooth,项目名称:pibooth,代码行数:14,代码来源:parser.py

示例11: gettyped

# 需要导入模块: from configparser import ConfigParser [as 别名]
# 或者: from configparser.ConfigParser import get [as 别名]
def gettyped(self, section, option):
        """Get a value from config and try to convert it in a native Python
        type (using the :py:mod:`ast` module).

        :param section: config section name
        :type section: str
        :param option: option name
        :type option: str
        """
        value = self.get(section, option)
        try:
            return ast.literal_eval(value)
        except (ValueError, SyntaxError):
            return value 
开发者ID:pibooth,项目名称:pibooth,代码行数:16,代码来源:parser.py

示例12: getpath

# 需要导入模块: from configparser import ConfigParser [as 别名]
# 或者: from configparser.ConfigParser import get [as 别名]
def getpath(self, section, option):
        """Get a path from config, evaluate the absolute path from configuration
        file path.

        :param section: config section name
        :type section: str
        :param option: option name
        :type option: str
        """
        return self._get_abs_path(self.get(section, option)) 
开发者ID:pibooth,项目名称:pibooth,代码行数:12,代码来源:parser.py

示例13: __getitem__

# 需要导入模块: from configparser import ConfigParser [as 别名]
# 或者: from configparser.ConfigParser import get [as 别名]
def __getitem__(self, name, raw=False, vars=None):
            """Fetch a value via the dict handler"""
            if name not in simpleconfigparser.Section.__dict__:
                return self.parser.get(self.section, name, raw, vars) 
开发者ID:morpheus65535,项目名称:bazarr,代码行数:6,代码来源:__init__.py

示例14: __getattr__

# 需要导入模块: from configparser import ConfigParser [as 别名]
# 或者: from configparser.ConfigParser import get [as 别名]
def __getattr__(self, name, raw=False, vars=None):
            """Fetch a value via the object handler"""
            if name not in simpleconfigparser.Section.__dict__:
                return self.parser.get(self.section, name, raw, vars) 
开发者ID:morpheus65535,项目名称:bazarr,代码行数:6,代码来源:__init__.py

示例15: get

# 需要导入模块: from configparser import ConfigParser [as 别名]
# 或者: from configparser.ConfigParser import get [as 别名]
def get(self, section, option, raw=False, vars=None, fallback=None):
        try:
            # Strip out quotes from the edges
            return configparser.get(self, section, option).strip('"\'')
        except NoOptionError:
            return None 
开发者ID:morpheus65535,项目名称:bazarr,代码行数:8,代码来源:__init__.py


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