コード例 #1
0
    def setUp(self):

        # trivial case without any nested sequences

        log.setLevel(DEBUG)

        dummyCfgFlags = AthConfigFlags()
        dummyCfgFlags.lock()

        def AlgsConf1(flags):
            acc = ComponentAccumulator()
            a1 = TestAlgo("Algo1")
            a2 = TestAlgo("Algo2")
            return acc, [a1, a2]

        def AlgsConf2(flags):
            acc = ComponentAccumulator()
            result, algs = AlgsConf1(flags)
            acc.merge(result)
            a = TestAlgo("Algo3")
            print("algo3 when created %s" % id(a))
            algs.append(a)
            return acc, algs

        acc = ComponentAccumulator()

        # top level algs
        acc1, algs = AlgsConf2(dummyCfgFlags)
        acc.merge(acc1)
        acc.addEventAlgo(algs)

        def AlgsConf3(flags):
            acc = ComponentAccumulator()
            na1 = TestAlgo("NestedAlgo1")
            return acc, na1

        def AlgsConf4(flags):
            acc, na1 = AlgsConf3(flags)
            NestedAlgo2 = TestAlgo("NestedAlgo2")
            NestedAlgo2.OutputLevel = 7
            return acc, na1, NestedAlgo2

        acc.addSequence(seqAND("Nest"))
        acc.addSequence(seqAND("subSequence1"), parentName="Nest")
        acc.addSequence(parOR("subSequence2"), parentName="Nest")

        acc.addSequence(seqAND("sub2Sequence1"), parentName="subSequence1")
        acc.addSequence(seqAND("sub3Sequence1"), parentName="subSequence1")
        acc.addSequence(seqAND("sub4Sequence1"), parentName="subSequence1")

        accNA1 = AlgsConf4(dummyCfgFlags)
        acc.merge(accNA1[0])
        acc.addEventAlgo(accNA1[1:], "sub2Sequence1")
        outf = open("testFile.pkl", "wb")
        acc.store(outf)
        outf.close()
        self.acc = acc
コード例 #2
0
print(acf.x.flag1)
print(acf.x.flag3)

#acf.addFlag("flag4", lambda prev: prev.get("flag5")*2 )
#acf.addFlag("flag5", lambda prev: prev.get("flag4")*2 )
#print (acf.get("flag4") -> Circular dependency!  )


acf.addFlag("domain1.flag1","bla")
acf.addFlag("domain1.flag2",lambda prev: prev.domain1.flag1*2)
acf.addFlag("domain2.flag1","geh")
acf.addFlag("domain2.flag2","xyz")
#acf.addFlag("domain2.flagxxx","will fail")

acf.lock()

print("Initial flag container")
acf.dump()

acfPrime=acf.clone()
acfPrime.flag3 = 42

print("Cloned flag container")
acfPrime.dump()

acfMod=acf.cloneAndReplace("domain1","domain2")

print("After cloneAndReplace")
acfMod.dump()