本文整理汇总了Python中DIRAC.Core.Utilities.CFG.CFG.listSections方法的典型用法代码示例。如果您正苦于以下问题:Python CFG.listSections方法的具体用法?Python CFG.listSections怎么用?Python CFG.listSections使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.Core.Utilities.CFG.CFG
的用法示例。
在下文中一共展示了CFG.listSections方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getComputingElementDefaults
# 需要导入模块: from DIRAC.Core.Utilities.CFG import CFG [as 别名]
# 或者: from DIRAC.Core.Utilities.CFG.CFG import listSections [as 别名]
def getComputingElementDefaults(ceName='', ceType='', cfg=None, currentSectionPath=''):
"""
Return cfgDefaults with defaults for the given CEs defined either in arguments or in the provided cfg
"""
cesCfg = CFG()
if cfg:
try:
cesCfg.loadFromFile(cfg)
cesPath = cfgInstallPath('ComputingElements')
if cesCfg.isSection(cesPath):
for section in cfgPathToList(cesPath):
cesCfg = cesCfg[section]
except BaseException:
return CFG()
# Overwrite the cfg with Command line arguments
if ceName:
if not cesCfg.isSection(ceName):
cesCfg.createNewSection(ceName)
if currentSectionPath:
# Add Options from Command Line
optionsDict = __getExtraOptions(currentSectionPath)
for name, value in optionsDict.items():
cesCfg[ceName].setOption(name, value) # pylint: disable=no-member
if ceType:
cesCfg[ceName].setOption('CEType', ceType) # pylint: disable=no-member
ceDefaultSection = cfgPath(defaultSection('ComputingElements'))
# Load Default for the given type from Central configuration is defined
ceDefaults = __gConfigDefaults(ceDefaultSection)
for ceName in cesCfg.listSections():
if 'CEType' in cesCfg[ceName]:
ceType = cesCfg[ceName]['CEType']
if ceType in ceDefaults:
for option in ceDefaults[ceType].listOptions(): # pylint: disable=no-member
if option not in cesCfg[ceName]:
cesCfg[ceName].setOption(option, ceDefaults[ceType][option]) # pylint: disable=unsubscriptable-object
return cesCfg
示例2: getComputingElementDefaults
# 需要导入模块: from DIRAC.Core.Utilities.CFG import CFG [as 别名]
# 或者: from DIRAC.Core.Utilities.CFG.CFG import listSections [as 别名]
def getComputingElementDefaults(ceName="", ceType="", cfg=None, currentSectionPath=""):
"""
Return cfgDefaults with defaults for the given CEs defined either in arguments or in the provided cfg
"""
cesCfg = CFG()
if cfg:
try:
cesCfg.loadFromFile(cfg)
cesPath = cfgInstallPath("ComputingElements")
if cesCfg.isSection(cesPath):
for section in cfgPathToList(cesPath):
cesCfg = cesCfg[section]
except:
return CFG()
# Overwrite the cfg with Command line arguments
if ceName:
if not cesCfg.isSection(ceName):
cesCfg.createNewSection(ceName)
if currentSectionPath:
# Add Options from Command Line
optionsDict = __getExtraOptions(currentSectionPath)
for name, value in optionsDict.items():
cesCfg[ceName].setOption(name, value)
if ceType:
cesCfg[ceName].setOption("CEType", ceType)
ceDefaultSection = cfgPath(defaultSection("ComputingElements"))
# Load Default for the given type from Central configuration is defined
ceDefaults = __gConfigDefaults(ceDefaultSection)
for ceName in cesCfg.listSections():
if "CEType" in cesCfg[ceName]:
ceType = cesCfg[ceName]["CEType"]
if ceType in ceDefaults:
for option in ceDefaults[ceType].listOptions():
if option not in cesCfg[ceName]:
cesCfg[ceName].setOption(option, ceDefaults[ceType][option])
return cesCfg