本文整理汇总了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
示例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")
示例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)