本文整理汇总了Python中IOTools.convertValue方法的典型用法代码示例。如果您正苦于以下问题:Python IOTools.convertValue方法的具体用法?Python IOTools.convertValue怎么用?Python IOTools.convertValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOTools
的用法示例。
在下文中一共展示了IOTools.convertValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: configToDictionary
# 需要导入模块: import IOTools [as 别名]
# 或者: from IOTools import convertValue [as 别名]
def configToDictionary( config ):
p = {}
for section in config.sections():
for key,value in config.items( section ):
v = IOTools.convertValue( value )
p["%s_%s" % (section,key)] = v
if section in ( "general", "DEFAULT" ):
p["%s" % (key)] = v
for key, value in config.defaults().iteritems():
p["%s" % (key)] = IOTools.convertValue( value )
return p
示例2: getParameters
# 需要导入模块: import IOTools [as 别名]
# 或者: from IOTools import convertValue [as 别名]
def getParameters( filename = "pipeline.ini" ):
'''read a config file and return as a dictionary.
Sections and keys are combined with an underscore. If
a key without section does not exist, it will be added
plain.
For example::
[general]
input=input1.file
[special]
input=input2.file
will be entered as { 'general_input' : "input1.file",
'input: "input1.file", 'special_input' : "input2.file" }
This function also updates the module-wide parameter map.
'''
p = {}
config = ConfigParser.ConfigParser()
config.readfp(open(filename),"r")
for section in config.sections():
for key,value in config.items( section ):
v = IOTools.convertValue( value )
if key not in p: p[key] = v
p["%s_%s" % (section,key)] = v
PARAMS.update( p )
return p