本文整理汇总了Python中myutils.BetterConfigParser.sections方法的典型用法代码示例。如果您正苦于以下问题:Python BetterConfigParser.sections方法的具体用法?Python BetterConfigParser.sections怎么用?Python BetterConfigParser.sections使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类myutils.BetterConfigParser
的用法示例。
在下文中一共展示了BetterConfigParser.sections方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: diffConfigFile
# 需要导入模块: from myutils import BetterConfigParser [as 别名]
# 或者: from myutils.BetterConfigParser import sections [as 别名]
def diffConfigFile(tag1, tag2, fileName):
print("file:", fileName)
config1 = BetterConfigParser()
config2 = BetterConfigParser()
config1.read(tag1 + 'config/' + fileName)
config2.read(tag2 + 'config/' + fileName)
sections = list(set(config1.sections() + config2.sections()))
commonSections = [x for x in sections if x in config1.sections() and x in config2.sections()]
print("common sections:", commonSections)
for section in commonSections:
firstItemInSection = True
items1d = {x[0]:x[1] for x in config1.items(section, raw=True)}
items2d = {x[0]:x[1] for x in config2.items(section, raw=True)}
items1 = [x[0] for x in config1.items(section, raw=True)]
items2 = [x[0] for x in config2.items(section, raw=True)]
items = list(set(items1 + items2))
commonItems = list(set([x for x in items if x in items1 and x in items2]))
for item in commonItems:
if item not in os.environ:
try:
item1 = config1.get(section, item)
item2 = config2.get(section, item)
item1 = items1d[item]
item2 = items2d[item]
if item1 != item2:
if firstItemInSection:
firstItemInSection = False
print('-'*80)
print(' \x1b[34m' + fileName + '\x1b[0m: ' + section)
print('-'*80)
print(section + ':' + item)
d = difflib.Differ()
result = list(d.compare([item1], [item2]))
for line in result:
if line.startswith('+'):
color = '\x1b[31m'
elif line.startswith('-'):
color = '\x1b[32m'
elif line.startswith('?'):
color = '\x1b[34m'
print(' '+color+line+'\x1b[0m')
except Exception as e:
pass
示例2: getStichWeight
# 需要导入模块: from myutils import BetterConfigParser [as 别名]
# 或者: from myutils.BetterConfigParser import sections [as 别名]
#runInParallel(getExtWeights, arglist)
#print 'Weights for HT 0 are', getStichWeight(ZLLjetsHT0 , ZLLBjets, HT0 +"&&"+DYBJets)
#print 'Weights for HT 70 are', getStichWeight(ZLLjetsHT70 , ZLLBjets, HT70 +"&&"+DYBJets)
#print 'Weights for HT 100 are', getStichWeight(ZLLjetsHT100 , ZLLBjets, HT100 +"&&"+DYBJets)
#print 'Weights for HT 200 are', getStichWeight(ZLLjetsHT200 , ZLLBjets, HT200 +"&&"+DYBJets)
#print 'Weights for HT 400 are', getStichWeight(ZLLjetsHT400 , ZLLBjets, HT400 +"&&"+DYBJets)
#print 'Weights for HT 600 are', getStichWeight(ZLLjetsHT600 , ZLLBjets, HT600 +"&&"+DYBJets)
#print 'Weights for HT 800 are', getStichWeight(ZLLjetsHT800 , ZLLBjets, HT800 +"&&"+DYBJets)
#print 'Weights for HT 1200 are', getStichWeight(ZLLjetsHT1200, ZLLBjets, HT1200+"&&"+DYBJets)
#print 'Weights for HT 2500 are', getStichWeight(ZLLjetsHT2500, ZLLBjets, HT2500+"&&"+DYBJets)
computeExtWeights = False
if computeExtWeights:
for section in config.sections():
#try:
# sampleName = config.get(section, 'sampleName')
#except:
sampleName = section
sampleNameShort = '_'.join(sampleName.split('_')[0:7]).strip()
if '_ext' in sampleName:
sampleNameShort = sampleNameShort.split('_ext')[0]
elif '_backup' in sampleName:
sampleNameShort = sampleNameShort.split('_backup')[0]
if sampleNameShort in sampleDict:
sampleDict[sampleNameShort].append(sampleName)
else:
sampleDict[sampleNameShort] = [sampleName]
示例3: BetterConfigParser
# 需要导入模块: from myutils import BetterConfigParser [as 别名]
# 或者: from myutils.BetterConfigParser import sections [as 别名]
#!/usr/bin/env python
from __future__ import print_function
import sys, ROOT, warnings
ROOT.gROOT.SetBatch(True)
#suppres the EvalInstace conversion warning bug
warnings.filterwarnings( action='ignore', category=RuntimeWarning, message='creating converter.*' )
from optparse import OptionParser
from myutils import BetterConfigParser, mvainfo, ParseInfo
#paths.ini general.ini cuts.ini training.ini datacards.ini plots.ini lhe_weights.ini samples_nosplit.ini
# load config
config = BetterConfigParser()
config.read('/mnt/t3nfs01/data01/shome/berger_p2/VHbb/CMSSW_9_4_0_pre3/src/Xbb/python/Zll2016config/paths.ini')
config.read('/mnt/t3nfs01/data01/shome/berger_p2/VHbb/CMSSW_9_4_0_pre3/src/Xbb/python/Zll2016config/general.ini')
config.read('/mnt/t3nfs01/data01/shome/berger_p2/VHbb/CMSSW_9_4_0_pre3/src/Xbb/python/Zll2016config/cuts.ini')
config.read('/mnt/t3nfs01/data01/shome/berger_p2/VHbb/CMSSW_9_4_0_pre3/src/Xbb/python/Zll2016config/training.ini')
config.read('/mnt/t3nfs01/data01/shome/berger_p2/VHbb/CMSSW_9_4_0_pre3/src/Xbb/python/Zll2016config/datacards.ini')
config.read('/mnt/t3nfs01/data01/shome/berger_p2/VHbb/CMSSW_9_4_0_pre3/src/Xbb/python/Zll2016config/plots.ini')
config.read('/mnt/t3nfs01/data01/shome/berger_p2/VHbb/CMSSW_9_4_0_pre3/src/Xbb/python/Zll2016config/lhe_weights.ini')
config.read('/mnt/t3nfs01/data01/shome/berger_p2/VHbb/CMSSW_9_4_0_pre3/src/Xbb/python/Zll2016config/samples_nosplit.ini')
print(config)
print(config.sections())
print(config.get('DYJetsToLL_M-50_HT-200to400_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_ext1', 'specialweight'))