本文整理汇总了Python中myutils.BetterConfigParser.write方法的典型用法代码示例。如果您正苦于以下问题:Python BetterConfigParser.write方法的具体用法?Python BetterConfigParser.write怎么用?Python BetterConfigParser.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类myutils.BetterConfigParser
的用法示例。
在下文中一共展示了BetterConfigParser.write方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _setup_configfiles
# 需要导入模块: from myutils import BetterConfigParser [as 别名]
# 或者: from myutils.BetterConfigParser import write [as 别名]
def _setup_configfiles(self, Testboard):
""" Changes config files in the already copied test directory according to test definitions
from elComandante's init file. """
# Delete all root files which are already in the directory
root_files = glob.glob(Testboard.testdir+'/*.root')
for f in root_files:
os.remove(f)
# Change testboard name
if Testboard.DTB and os.path.isfile(Testboard.testdir + "/tb"):
self._config_file_content_substitute(Testboard.testdir + "/tb", {"id":Testboard.address})
else:
self._config_file_content_substitute(Testboard.testdir + "/configParameters.dat", {"testboardName":Testboard.address})
# Get test specific config parameters (if available)
params = ()
try:
params = self.init.items("Test " + self.test.testname)
except:
return
for par in params:
file = par[0]
if '.cfg' in file:
section,pair = par[1].split(':')
key,value = pair.split('=')
config_file = BetterConfigParser()
config_file.read(Testboard.testdir + "/" + file)
config_file.set(section,key,value)
write_file = open(Testboard.testdir + "/" + file, 'write')
config_file.write(write_file)
write_file.close()
continue
# Check for valid keys that represent config files
elif "testParameters" in file or "dacParameters" in file or "configParameters" in file:
pass
elif "tbmParameters" in file or "tbParameters" in file:
pass
else:
continue
encoded_keys = par[1].split(",")
keys = {}
for key in encoded_keys:
key = key.split("=", 2)
if len(key) != 2:
continue
keys[key[0]] = key[1]
if len(file) < 4 or file[-4:] != ".dat":
file += ".dat"
self._config_file_content_substitute(Testboard.testdir + "/" + file, keys)
示例2: get_weights
# 需要导入模块: from myutils import BetterConfigParser [as 别名]
# 或者: from myutils.BetterConfigParser import write [as 别名]
canvas = ROOT.TCanvas("lheV_pt","lheV_pt",600,600)
ROOT.gPad.SetLogy()
histo.Draw()
histo1.Draw('SAME')
#print histo.Integral(100,300)
#print histo1.Integral(100,300)
histo1.SetLineColor(ROOT.kRed)
canvas.Print("validation_lheV_pt.pdf","pdf")
if opts.weights:
weight_map = get_weights(fileList,lheBin)
config.set('lheWeights', 'weights_per_bin', '%s' %weight_map)
f = open('13TeVconfig/lheWeights', 'w')
for section in config.sections():
if not section == 'lheWeights':
config.remove_section(section)
config.write(f)
f.close()
elif opts.apply:
weight_map = eval(config.get('lheWeights', 'weights_per_bin'))
if opts.apply:
apply_weights(fileList,weight_map,prefix+inclusive,newpostfix)
if opts.validate:
do_validation(fileList,inclusive,newpostfix)