当前位置: 首页>>代码示例>>Python>>正文


Python myutils.BetterConfigParser类代码示例

本文整理汇总了Python中myutils.BetterConfigParser的典型用法代码示例。如果您正苦于以下问题:Python BetterConfigParser类的具体用法?Python BetterConfigParser怎么用?Python BetterConfigParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BetterConfigParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _setup_configfiles

    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)
开发者ID:fnal,项目名称:elComandante,代码行数:50,代码来源:psi_agente.py

示例2: __init__

    def __init__(self, TB, client, psiSubscription, Logger, color='black', psiVersion='psi46expert'):
        self.TB = TB
        self.client = client
        self.psiSubscription = psiSubscription
        self.color = color
        self.Logger = Logger
        self.TBSubscription = '/TB%s'%self.TB
        self.client.subscribe(self.TBSubscription)
        self.dir = ''
        self.psiVersion = psiVersion
        if self.psiVersion.lower().endswith("psi46expert"):
            self.version ='psi46expert'
        elif self.psiVersion.lower().endswith("pyxar"):
            self.version ='pyxar'
        elif self.psiVersion.lower().endswith("pxar"):
            self.version ='pxar'
        else:
            self.version = 'unknown'
        self.failed = False
        self.busy = False
        self.testName ='unkown'
        self.testNo = -1
        self.TestEnd = False
        self.DoTest= False
        self.ClosePSI= False
        self.Abort = False
        self.LogFile = ""
        self.RootFile = ""
        # default value in Vcal units, -1 means use untrimmed parameters
        #  this setting is overwritten if [Test Trim] is specified in the ini file
        #  containg testParameters=Vcal=*
        self.trimVcal = -1 

        self.init = BetterConfigParser()
        self.init.read("../config/elComandante.ini")
        try:
            testParameters = self.init.get('Test Trim','testParameters')
            pos1 = testParameters.find("=")
            if pos1 > 0:
                testParametersName = testParameters[0:pos1]
                testParametersValue = testParameters[pos1+1:]
                if testParametersName.lower() == "vcal":
                    self.trimVcal = int(testParametersValue)
                    self.Logger << "TB%s: using option '-T %s' when calling pxar"%(self.TB, self.trimVcal)
        except:
            self.Logger << "TB%s: no [Test Trim] section found in ini file, using untrimmed parameters"%self.TB
开发者ID:fnal,项目名称:elComandante,代码行数:46,代码来源:tbmaster.py

示例3: __init__

    def __init__(self, opts):

        # get file list
        self.filelist = FileList.decompress(opts.fileList) if len(opts.fileList) > 0 else None
        print "len(filelist)",len(self.filelist),
        if len(self.filelist) > 0:
            print "filelist[0]:", self.filelist[0]
        else:
            print ''

        # config
        self.debug = 'XBBDEBUG' in os.environ
        self.verifyCopy = True
        self.opts = opts
        self.config = BetterConfigParser()
        self.config.read(opts.config)
        samplesinfo = self.config.get('Directories', 'samplesinfo')
        self.channel = self.config.get('Configuration', 'channel')

        # load namespace, TODO
        VHbbNameSpace = self.config.get('VHbbNameSpace', 'library')
        ROOT.gSystem.Load(VHbbNameSpace)

        # directories
        self.pathIN = self.config.get('Directories', opts.inputDir)
        self.pathOUT = self.config.get('Directories', opts.outputDir)
        self.tmpDir = self.config.get('Directories', 'scratch')
        print 'INput samples:\t%s'%self.pathIN
        print 'OUTput samples:\t%s'%self.pathOUT

        self.fileLocator = FileLocator(config=self.config)

        # check if given sample identifier uniquely matches a samples from config
        matchingSamples = ParseInfo(samplesinfo, self.pathIN).find(identifier=opts.sampleIdentifier)
        if len(matchingSamples) != 1:
            print "ERROR: need exactly 1 sample identifier as input with -S !!"
            print matchingSamples
            exit(1)
        self.sample = matchingSamples[0]

        # collections
        self.collections = [x.strip() for x in opts.addCollections.split(',') if len(x.strip()) > 0] if len(opts.addCollections.strip())>0  else []
        if len(self.collections) < 1:
            print "\x1b[31mWARNING: no collections added! Specify the collections to add with the --addCollections option!\x1b[0m"
        print 'collections to add:', self.collections
        self.collections = self.parseCollectionList(self.collections)
        print 'after parsing:', self.collections

        # temorary folder to save the files of this job on the scratch
        temporaryName = self.sample.identifier + '/' + uuid.uuid4().hex

        # input files
        self.subJobs = []
        if opts.join:
            print("INFO: join input files! This is an experimental feature!")

            # translate naming convention of .txt file to imported files after the prep step
            inputFileNamesAfterPrep = [self.fileLocator.getFilenameAfterPrep(x) for x in self.filelist]

            self.subJobs.append({
                'inputFileNames': self.filelist,
                'localInputFileNames': ["{path}/{subfolder}/{filename}".format(path=self.pathIN, subfolder=self.sample.identifier, filename=localFileName) for localFileName in inputFileNamesAfterPrep],
                'outputFileName': "{path}/{subfolder}/{filename}".format(path=self.pathOUT, subfolder=self.sample.identifier, filename=inputFileNamesAfterPrep[0]),
                'tmpFileName': "{path}/{subfolder}/{filename}".format(path=self.tmpDir, subfolder=temporaryName, filename=inputFileNamesAfterPrep[0]),
                })

        else:
            
            # create separate subjob for all files (default!)
            for inputFileName in self.filelist:
                inputFileNamesAfterPrep = [self.fileLocator.getFilenameAfterPrep(inputFileName)]

                self.subJobs.append({
                    'inputFileNames': [inputFileName],
                    'localInputFileNames': ["{path}/{subfolder}/{filename}".format(path=self.pathIN, subfolder=self.sample.identifier, filename=localFileName) for localFileName in inputFileNamesAfterPrep],
                    'outputFileName': "{path}/{subfolder}/{filename}".format(path=self.pathOUT, subfolder=self.sample.identifier, filename=inputFileNamesAfterPrep[0]),
                    'tmpFileName': "{path}/{subfolder}/{filename}".format(path=self.tmpDir, subfolder=temporaryName, filename=inputFileNamesAfterPrep[0]),
                    })
开发者ID:GLP90,项目名称:Xbb,代码行数:78,代码来源:sys_new.py

示例4: countEvents

            #print fileMask
            extPartFiles = glob.glob(fileMask)
            #print extPart,"=>",len(extPartFiles),"files"
            extPartCounts[extPart] = 0
            for extPartFile in extPartFiles:
                extPartCounts[extPart] += countEvents(t3proto + '/' + extPartFile)
                #root://t3dcachedb03.psi.ch:1094
    
    # get total count
    totalCount = sum([n for sampleName,n in extPartCounts.iteritems()])

    # relative weights
    for sampleName,n in extPartCounts.iteritems():
        print sampleName,":",(1.0*n/totalCount if totalCount > 0 else '-')

config = BetterConfigParser()
configPath = sys.argv[1] + '/samples_nosplit.ini'
config.read(configPath)
configPath = sys.argv[1] + '/paths.ini'
config.read(configPath)

sampleDict = {}
sampleWeights = {}
verify = len(sys.argv) > 2 and sys.argv[2]=='verify'

##############
#Specialweight
##############

#ZLLIncl = ["DYJetsToLL_M-50_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_ext1","DYJetsToLL_M-50_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_ext2"]
#
开发者ID:GLP90,项目名称:Xbb,代码行数:31,代码来源:getExtWeights.py

示例5: BetterConfigParser

if opts.task == "":
    print "Please provide a task.\n-J prep:\tpreparation of Trees\n-J sys:\t\twrite regression and systematics\n-J eval:\tcreate MVA output\n-J plot:\tproduce Plots\n-J dc:\t\twrite workspaces and datacards"
    sys.exit(123)


en = opts.tag

#create the list with the samples to run over
samplesList=opts.samples.split(",")
timestamp = time.asctime().replace(' ','_').replace(':','-')

if(debugPrintOUts): print 'samplesList',samplesList
if(debugPrintOUts): print 'timestamp',timestamp

# the list of the config is taken from the path config
pathconfig = BetterConfigParser()
pathconfig.read('%sconfig/paths'%(en))
_configs = pathconfig.get('Configuration','List').split(" ")
configs = [ '%sconfig/'%(en) + c for c in _configs  ]

if(debugPrintOUts): print 'configs',configs
if(debugPrintOUts): print 'opts.ftag',opts.ftag

if not opts.ftag == '':
    tagDir = pathconfig.get('Directories','tagDir')
    # DEBUG PURPOSE ONLY        
    # sys.exit()
    if(debugPrintOUts): print 'tagDir',tagDir
    DirStruct={'tagDir':tagDir,'ftagdir':'%s/%s/'%(tagDir,opts.ftag),'logpath':'%s/%s/%s/'%(tagDir,opts.ftag,'Logs'),'plotpath':'%s/%s/%s/'%(tagDir,opts.ftag,'Plots'),'limitpath':'%s/%s/%s/'%(tagDir,opts.ftag,'Limits'),'confpath':'%s/%s/%s/'%(tagDir,opts.ftag,'config') }
    
    if(debugPrintOUts): print 'DirStruct',DirStruct
开发者ID:perrozzi,项目名称:VHbb,代码行数:31,代码来源:submitThem.py

示例6: BetterConfigParser

parser.add_option("-S","--setting", dest="MVAsettings", default='',
                      help="Parameter setting string")
parser.add_option("-N","--name", dest="set_name", default='',
                      help="Parameter setting name. Output files will have this name")
parser.add_option("-L","--local",dest="local", default=True,
                      help="True to run it locally. False to run on batch system using config")

(opts, args) = parser.parse_args(argv)
if opts.config =="":
        opts.config = "config"

#Import after configure to get help message
from myutils import BetterConfigParser, mvainfo, ParseInfo, TreeCache

#load config
config = BetterConfigParser()
config.read(opts.config)
anaTag = config.get("Analysis","tag")
run = opts.training
gui = opts.verbose

print '-----> Input Training Sample(s): ', run

#GLOABAL rescale from Train/Test Spliiting:
global_rescale=2.

#get locations:
MVAdir      = config.get('Directories','vhbbpath')+'/data/'
samplesinfo = config.get('Directories','samplesinfo')

#systematics
开发者ID:dcurry09,项目名称:Heppy,代码行数:31,代码来源:train.py

示例7: OptionParser

argv = sys.argv
parser = OptionParser()
#parser.add_option("-P", "--path", dest="path", default="", 
#                      help="path to samples")
parser.add_option("-S", "--samples", dest="names", default="", 
                      help="samples you want to run on")
parser.add_option("-C", "--config", dest="config", default=[], action="append",
                      help="configuration defining the plots to make")
(opts, args) = parser.parse_args(argv)
if opts.config =="":
        opts.config = "config"

from myutils import BetterConfigParser, ParseInfo

print opts.config
config = BetterConfigParser()
config.read(opts.config)
anaTag = config.get("Analysis","tag")
TrainFlag = eval(config.get('Analysis','TrainFlag'))
btagLibrary = config.get('BTagReshaping','library')
samplesinfo=config.get('Directories','samplesinfo')

VHbbNameSpace=config.get('VHbbNameSpace','library')
ROOT.gSystem.Load(VHbbNameSpace)
AngLikeBkgs=eval(config.get('AngularLike','backgrounds'))
ang_yield=eval(config.get('AngularLike','yields'))

#path=opts.path
pathIN = config.get('Directories','SYSin')
pathOUT = config.get('Directories','SYSout')
tmpDir = os.environ["TMPDIR"]
开发者ID:perrozzi,项目名称:VHbb,代码行数:31,代码来源:write_regression_systematics.py

示例8: BetterConfigParser

parser.add_option("-C", "--config", dest="config", default=[], action="append",
                              help="configuration defining bins")
parser.add_option("-A", "--apply", dest="apply", default=True, action="store_true",
                              help="configuration defining the")
parser.add_option("-W", "--weight", dest="weights", default=True, action="store_false",
                              help="Calculate the weights")
parser.add_option("-V", "--validate", dest="validate", default=False, action="store_false",
                              help="Make validation plot the weights")
(opts, args) = parser.parse_args(argv)
if opts.config =="":
    opts.config = "config"

from myutils import BetterConfigParser

print opts.config
config = BetterConfigParser()
config.read(opts.config)
prefix = config.get('lheWeights','prefix')
newpostfix = config.get('lheWeights','newpostfix')
inclusive = config.get('lheWeights','inclusive')
files = eval(config.get('lheWeights','fileList'))
lheBin = eval(config.get('lheWeights','lheBin'))

print '\n========= Looping over Drell Yan Samples ==========\n'

fileList = []
for file in files:
    new_entry = [prefix+file+'.root',files[file],[]]
    print new_entry
    if file == inclusive:
        fileList.insert(0, new_entry)
开发者ID:dcurry09,项目名称:Heppy,代码行数:31,代码来源:addingSamples.py

示例9: OptionParser

            newLine += words[i].ljust(maxColumnWidth[i]+1)
        file_.write(newLine+'\n')
    file_.close()
    return



#--CONFIGURE---------------------------------------------------------------------
argv = sys.argv
parser = OptionParser()
parser.add_option("-V", "--variable", dest="variable", default="",
                      help="variable for shape analysis")
parser.add_option("-C", "--config", dest="config", default=[], action="append",
                      help="configuration file")
(opts, args) = parser.parse_args(argv)
config = BetterConfigParser()
config.read(opts.config)
var=opts.variable
#-------------------------------------------------------------------------------

# Add external macros
#ROOT.gSystem.CompileMacro("../plugins/PU.C")

#--read variables from config---------------------------------------------------
# 7 or 8TeV Analysis
anaTag = config.get("Analysis","tag")

# Directories:
Wdir=config.get('Directories','Wdir')
vhbbpath=config.get('Directories','vhbbpath')
samplesinfo=config.get('Directories','samplesinfo')
开发者ID:dcurry09,项目名称:Heppy,代码行数:31,代码来源:workspace_datacard.py

示例10: getEventCount

# 1) ./getExtWeights.py configname
# 2) ./getExtWeight.py configname verify

def getEventCount(config, sampleIdentifier, cut="1", sampleTree=None):
    if not sampleTree:
        sampleTree = SampleTree({'name': sampleIdentifier, 'folder': config.get('Directories',args.fromFolder).strip()}, config=config)
    h1 = ROOT.TH1D("h1","h1",1,0,2)
    nEvents = sampleTree.tree.Draw("1>>h1", "(" + cut + ")*genWeight")
    nEventsWeighted = h1.GetBinContent(1)
    h1.Delete()
    return nEventsWeighted


# load config
config = BetterConfigParser()
configFolder = args.tag + 'config/'
print "config folder:", configFolder
config.read(configFolder + '/paths.ini')
configFiles = [x for x in config.get('Configuration','List').strip().split(' ') if len(x.strip()) > 0]
config = BetterConfigParser()
for configFile in configFiles:
    config.read(configFolder + configFile)
    print "read config ", configFile

pruneThreshold = float(args.prune)

sampleGroups = []
for x in args.samples.split(','):
    sampleGroups.append(x.split('+'))
开发者ID:GLP90,项目名称:Xbb,代码行数:29,代码来源:getExtWeightsNew.py

示例11: OptionParser

#!/usr/bin/env python
import ROOT

ROOT.gROOT.SetBatch(True)
from ROOT import TFile
from optparse import OptionParser
import sys
from myutils import BetterConfigParser, TdrStyles, getRatio


argv = sys.argv
parser = OptionParser()
parser.add_option("-C", "--config", dest="config", default=[], action="append", help="configuration file")
(opts, args) = parser.parse_args(argv)
config = BetterConfigParser()
config.read(opts.config)


# ---------- yes, this is not in the config yet---------
mode = "BDT"
xMin = -1
xMax = 1
masses = ["125"]
Abins = ["HighPt", "LowPt"]
channels = ["Zee", "Zmm"]
# ------------------------------------------------------
# ---------- Mjj ---------------------------------------
# mode = 'Mjj'
# xMin=0
# xMax=255
# masses = ['125']
开发者ID:silviodonato,项目名称:Xbb,代码行数:31,代码来源:plot_systematics.py

示例12: BetterConfigParser

parser.add_option("-o","--force", action="store_true", dest="force", default=False,
                      help="force overwriting of already cached files")
(opts, args) = parser.parse_args(argv)

if opts.config == "":
        opts.config = "config"

weight = opts.weight
evaluate_optimisation = False
if weight != '':
    evaluate_optimisation = True

#Import after configure to get help message
from myutils import BetterConfigParser, ParseInfo, MvaEvaluator

config = BetterConfigParser()
config.read(opts.config)
anaTag = config.get("Analysis", "tag")

fileLocator = FileLocator(config=config)
print ("OPTS", opts)
if len(opts.fileList) > 0:
    filelist = FileList.decompress(opts.fileList) if len(opts.fileList) > 0 else None
    print ("len(filelist)", len(filelist))
    if len(filelist) > 0:
        print ("filelist[0]:", filelist[0])
else:
    filelist = SampleTree({'name': opts.sampleIdentifier, 'folder': config.get('Directories', 'MVAin')}, countOnly=True, splitFilesChunkSize=-1, config=config).getSampleFileNameChunks()[0]
    print ("INFO: no file list given, use all files!")
    print (len(filelist), filelist)
开发者ID:GLP90,项目名称:Xbb,代码行数:30,代码来源:evaluateMVA.py

示例13: OptionParser

#!/usr/bin/env python
import os,sys,ROOT
from optparse import OptionParser
ROOT.gROOT.SetBatch(True)

#--CONFIGURE---------------------------------------------------------------------
argv = sys.argv
parser = OptionParser()
parser.add_option("-S", "--section", dest="section", default="Cuts",
                              help="Config section")
parser.add_option("-V", "--value", dest="var", default="",
                              help="Config value")
parser.add_option("-C", "--config", dest="config", default=[], action="append",
                              help="configuration file")
(opts, args) = parser.parse_args(argv)

from myutils import BetterConfigParser

config = BetterConfigParser()
config.read(opts.config)
print config.get(opts.section,opts.var)
开发者ID:GLP90,项目名称:Xbb,代码行数:21,代码来源:config_unroller.py

示例14: OptionParser


ROOT.gROOT.SetBatch(True)

# Import heppy configurations
argv = sys.argv
parser = OptionParser()
parser.add_option("-S", "--samples", dest="names", default="",
                                        help="samples you want to run on")
parser.add_option("-C", "--config", dest="config", default=[], action="append",
                                        help="configuration defining the plots to make")
(opts, args) = parser.parse_args(argv)
if opts.config =="":
            opts.config = "config"

config = BetterConfigParser()
config.read(opts.config)

samplesinfo = config.get('Directories','samplesinfo')

tmpDir = os.environ["TMPDIR"]

pathIN = config.get('Directories','SYSout')
pathOUT = config.get('Directories','SYSout')

name = config.get('TrainRegression', 'name') 

namelist = opts.names.split(',')

info = ParseInfo(samplesinfo,pathIN)
开发者ID:dcurry09,项目名称:Heppy,代码行数:28,代码来源:kinFit_Hmass.py

示例15: BetterConfigParser

    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
                              help="Verbose mode.")
    parser.add_option("-C", "--config", dest="config", default=[], action="append",
                          help="configuration file")
    parser.add_option("-r","--regions", dest="regions", default='',
                          help="cut region identifiers, separated by comma")
    parser.add_option("-t","--type", dest="fitType", default='',
                          help="shapes_prefit, shapes_fit_b, shapes_fit_s")

    (opts, args) = parser.parse_args(argv)
    if opts.config == "":
            opts.config = ["config"]

    # Import after configure to get help message
    from myutils import BetterConfigParser, mvainfo, ParseInfo
    config = BetterConfigParser()
    config.read(opts.config)

    if len(opts.fitType) < 1:
        if config.has_option('Fit','FitType'):
            opts.fitType = config.get('Fit','FitType')
        else:
            opts.fitType = "shapes_prefit"

    # run plotter
    if len(opts.regions) < 1:
        regions = eval(config.get('Fit', 'regions')).keys()
    else:
        regions = opts.regions.split(',')
    for region in regions:
        plotter = PostfitPlotter(config=config, region=region, directory=opts.fitType)
开发者ID:GLP90,项目名称:Xbb,代码行数:31,代码来源:postfit_plot.py


注:本文中的myutils.BetterConfigParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。