當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。