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


Python ConfigParser._sections方法代码示例

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


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

示例1: _setup_config

# 需要导入模块: from ConfigParser import ConfigParser [as 别名]
# 或者: from ConfigParser.ConfigParser import _sections [as 别名]
    def _setup_config(cls):
        default_conf = ConfigParser()
        default_conf._sections = _DEFAULT_CONFIG
        try:
            if not path.exists(_USER_CONF_PATH):
                ConfigWriter.write_config(_DEFAULT_CONFIG, _USER_CONF_PATH)
                user_conf = ConfigParser()
                user_conf._sections = _DEFAULT_CONFIG
            else:
                user_conf = cls._read_config(_USER_CONF_PATH)
                ConfigChecker.check_config('user configuration',
                                           _USER_CONF_PATH,
                                           user_conf._sections)
        except MissingSection as e:
            solution = ('falling back to default configuration.'
                        '\nDelete configuration file to restore defaults')
            ConfigChecker.warn_user(e, solution)
            user_conf = ConfigParser()
            user_conf.add_section('Settings')
        except MissingSetting as e:
            solution = ('falling back to default configuration.'
                        '\nSpecify setting to avoid using defaults')
            ConfigChecker.warn_user(e, solution)

        cls._config = cls._compose_config(default_conf, user_conf)

        try:
            if platform == 'win32':
                maxima_path_list = PathFinder.find_path_to(
                    cls._config['maxima_path'])
                if not len(maxima_path_list) > 0:
                    raise IOError(2,
                                  'No valid path to specified file',
                                  cls._config['maxima_path'])

                maxima_path = sorted(maxima_path_list)[-1]
                cls._config['maxima_path'] = maxima_path
            else:
                maxima_path = PathFinder.which('maxima')
                if not maxima_path:
                    raise IOError(2,
                                  'Maxima not installed',
                                  'command not found')
                cls._config['maxima_path'] = 'maxima'
        except IOError as e:
            solution = ('Please check that configuration file specifies '
                        'the correct path for Maxima and '
                        'that Maxima is installed correctly before '
                        'attempting to generate new results with SymCA '
                        '(see documentation for details).')
            ConfigChecker.warn_user(e, solution)
            cls._config['maxima_path'] = None

        cls._config['platform'] = platform
        cls._config['stdout'] = stdout
开发者ID:PySCeS,项目名称:PyscesToolbox,代码行数:57,代码来源:config.py

示例2: makeParser

# 需要导入模块: from ConfigParser import ConfigParser [as 别名]
# 或者: from ConfigParser.ConfigParser import _sections [as 别名]
 def makeParser(fileName):
     parser = ConfigParser()
     # Default behaviour transforms to lower case: we want case-sensitive
     parser.optionxform = str
     # There isn't a nice way to change the behaviour on getting a duplicate section
     # so we use a nasty way :)
     parser._sections = ParserSectionDict(fileName)
     try:
         parser.read(fileName)
         parser._sections.readingFile = None
         return parser
     except Exception:
         plugins.printWarning("Bug file at " + fileName + " not understood, ignoring")
开发者ID:emilybache,项目名称:texttest-runner,代码行数:15,代码来源:__init__.py

示例3: makeParser

# 需要导入模块: from ConfigParser import ConfigParser [as 别名]
# 或者: from ConfigParser.ConfigParser import _sections [as 别名]
 def makeParser(self, fileName):
     parser = ConfigParser()
     # Default behaviour transforms to lower case: we want case-sensitive
     parser.optionxform = str
     parser._sections = seqdict()
     # There isn't a nice way to change the behaviour on getting a duplicate section
     # so we use a nasty way :)
     realLookup = parser._sections.__getitem__
     parser._sections.__getitem__ = plugins.Callable(self.lookupSection, fileName, realLookup)
     try:
         parser.read(fileName)
         parser._sections.__getitem__ = realLookup
         return parser
     except:
         plugins.printWarning("Bug file at " + fileName + " not understood, ignoring", stderr=True, stdout=False)
开发者ID:haddyclipk,项目名称:ICS,代码行数:17,代码来源:__init__.py


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