def test4Methods(self): """Test various methods of CfgItemList""" i = CfgItemList('MyItems') self.failUnless(i.name() == 'MyItems') i.add({'Klass': ['key1', 'key2']}) self.failUnless(i() == ['Klass#key1', 'Klass#key2']) i.add({'Klass': ['key1', 'key3']}) self.failUnless(i() == ['Klass#key1', 'Klass#key2', 'Klass#key3']) props = i.getProperties() self.failUnless(props.has_key('Klass')) self.failUnless(len(props['Klass']) == len(['key1', 'key2', 'key3'])) self.failUnless('key1' in props['Klass']) self.failUnless('key2' in props['Klass']) self.failUnless('key3' in props['Klass']) self.failUnless(len(i.allChildren()) == 0) self.failUnless(i.has_item('Klass#key1')) self.failUnless(i.has_item('Klass#key*')) self.failUnless(not i.has_item('Klass#Key1')) self.failUnless(not i.has_item('Klass#Key*')) i.clear() self.failUnless(len(i()) == 0) i.add({'Klass': ['key1', 'key2']}) self.failUnless(len(i()) == 2) i.remove('Klass') self.failUnless(len(i()) == 2) i.remove('Klass#key1') self.failUnless(len(i()) == 2) i.removeAll() self.failUnless(len(i()) == 2) i.removeItem('Klass') self.failUnless(len(i()) == 2) i.removeItem('Klass#key1') self.failUnless(len(i()) == 1) _keys = ['key1', 'key2', 'key3'] i.add({'Klass': _keys}) self.failUnless(len(i()) == 3) i.removeAllItems('Klass#key2') self.failUnless(len(i()) == 2) ## test we don't modify input dict d = {'Klassy': ['key1', 'key2', 'key3']} orig_d = d.copy() i.add(d) self.failUnless(d == orig_d) d = {'Klassy': 'key4'} orig_d = d.copy() i.add(d) self.failUnless(d == orig_d) ## test extraction of the item list of a given Container type _keys = ["Klassy#%s" % k for k in 'key1', 'key2', 'key3', 'key4'] self.failUnless(i("Klassy") == _keys) self.failUnless(i.list("Klassy") == _keys) self.failUnless(i(key="Klassy") == _keys) self.failUnless(i.list(key="Klassy") == _keys) ## test dict() _keys = ['key1', 'key2', 'key3', 'key4'] self.failUnless(i.dict()['Klass'] == ['key1', 'key3']) self.failUnless(i.dict()['Klassy'] == _keys) _dict = { 'Klass': ['key1', 'key3'], 'Klassy': ['key1', 'key2', 'key3', 'key4'] } self.failUnless(i.dict() == _dict)
'TRT_BSErrContainer#TRT_ByteStreamErrs', 'xAOD::TrigTrackCountsContainer#HLT_xAOD__TrigTrackCountsContainer_trackcounts', 'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_EFBMuMuFex', 'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_EFBMuMuXFex', 'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_EFBMuMuXFex_X', 'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_EFDsPhiPiFex', 'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_EFMuPairs', 'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_EFMultiMuFex', 'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_EFTrackMass', 'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_L2BMuMuFex', 'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_L2BMuMuXFex', 'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_L2DiMuXFex', 'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_L2DsPhiPiFexDs', 'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_L2DsPhiPiFexPhi', 'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_L2JpsieeFex', 'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_L2MultiMuFex', 'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_L2TrackMass', 'xAOD::TrigCompositeContainer#HLT_xAOD__TrigCompositeContainer_L1TopoComposite', 'xAOD::TrigCompositeContainer#HLT_xAOD__TrigCompositeContainer_L1TopoMET', 'xAOD::TrigCompositeContainer#HLT_xAOD__TrigCompositeContainer_MuonRoICluster', 'xAOD::L1TopoRawDataAuxContainer#L1TopoRawDataAux.', 'xAOD::ElectronTrigAuxContainer#HLT_xAOD__ElectronContainer_egamma_ElectronsAux.', 'xAOD::MuonSegmentAuxContainer#MuonSegmentsAux.', 'xAOD::MuonSegmentAuxContainer#NCB_MuonSegmentsAux.', 'Muon::TgcPrepDataContainer#TGC_MeasurementsAllBCs', 'DataHeader#StreamESD'] ) outList.removeAllItems(ExcludeList) StreamDESDM_PHOJET.AddItem(outList())
'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_EFMultiMuFex', 'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_EFTrackMass', 'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_L2BMuMuFex', 'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_L2BMuMuXFex', 'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_L2DiMuXFex', 'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_L2DsPhiPiFexDs', 'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_L2DsPhiPiFexPhi', 'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_L2JpsieeFex', 'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_L2MultiMuFex', 'xAOD::TrigBphysContainer#HLT_xAOD__TrigBphysContainer_L2TrackMass', 'xAOD::TrigCompositeContainer#HLT_xAOD__TrigCompositeContainer_L1TopoComposite', 'xAOD::TrigCompositeContainer#HLT_xAOD__TrigCompositeContainer_L1TopoMET', 'xAOD::TrigCompositeContainer#HLT_xAOD__TrigCompositeContainer_MuonRoICluster', 'xAOD::L1TopoRawDataAuxContainer#L1TopoRawDataAux.', 'xAOD::ElectronTrigAuxContainer#HLT_xAOD__ElectronContainer_egamma_ElectronsAux.', 'xAOD::MuonSegmentAuxContainer#MuonSegmentsAux.', 'xAOD::MuonSegmentAuxContainer#NCB_MuonSegmentsAux.', 'Muon::TgcPrepDataContainer#TGC_MeasurementsAllBCs', 'DataHeader#StreamESD'] ) # Remove items here, as needed outList.removeAllItems( 'RpcPadContainer#RPCPAD' ) # Avoids crash in 20.1.0.2 # Configure the stream HIPsStream.AddItem(outList()) # make sure bookkeeping info is kept for additional filters HIPsStream.AddOtherAlgsToBookkeep(filtersToBookkeep)
def test4Methods( self ): """Test various methods of CfgItemList""" i = CfgItemList( 'MyItems' ) self.failUnless( i.name() == 'MyItems' ) i.add( { 'Klass' : ['key1', 'key2'] } ) self.failUnless( i() == [ 'Klass#key1', 'Klass#key2' ] ) i.add( { 'Klass' : ['key1', 'key3' ] } ) self.failUnless( i() == [ 'Klass#key1', 'Klass#key2', 'Klass#key3' ] ) props = i.getProperties() self.failUnless( props.has_key( 'Klass' ) ) self.failUnless( len(props['Klass']) == len(['key1','key2','key3']) ) self.failUnless( 'key1' in props['Klass'] ) self.failUnless( 'key2' in props['Klass'] ) self.failUnless( 'key3' in props['Klass'] ) self.failUnless( len(i.allChildren()) == 0 ) self.failUnless( i.has_item( 'Klass#key1' ) ) self.failUnless( i.has_item( 'Klass#key*' ) ) self.failUnless( not i.has_item( 'Klass#Key1' ) ) self.failUnless( not i.has_item( 'Klass#Key*' ) ) i.clear() self.failUnless( len(i()) == 0 ) i.add( { 'Klass' : ['key1', 'key2'] } ) self.failUnless( len(i()) == 2 ) i.remove( 'Klass' ) self.failUnless( len(i()) == 2 ) i.remove( 'Klass#key1' ) self.failUnless( len(i()) == 2 ) i.removeAll() self.failUnless( len(i()) == 2 ) i.removeItem( 'Klass' ) self.failUnless( len(i()) == 2 ) i.removeItem( 'Klass#key1' ) self.failUnless( len(i()) == 1 ) _keys = ['key1', 'key2', 'key3'] i.add( { 'Klass' : _keys } ) self.failUnless( len(i()) == 3 ) i.removeAllItems( 'Klass#key2' ) self.failUnless( len(i()) == 2 ) ## test we don't modify input dict d = { 'Klassy' : ['key1', 'key2', 'key3'] } orig_d = d.copy() i.add( d ) self.failUnless( d == orig_d ) d = { 'Klassy' : 'key4' } orig_d = d.copy() i.add( d ) self.failUnless( d == orig_d ) ## test extraction of the item list of a given Container type _keys = [ "Klassy#%s" % k for k in 'key1', 'key2', 'key3', 'key4' ] self.failUnless( i( "Klassy" ) == _keys ) self.failUnless( i.list( "Klassy" ) == _keys ) self.failUnless( i( key = "Klassy" ) == _keys ) self.failUnless( i.list( key = "Klassy" ) == _keys ) ## test dict() _keys = [ 'key1', 'key2', 'key3', 'key4' ] self.failUnless( i.dict()['Klass' ] == ['key1', 'key3'] ) self.failUnless( i.dict()['Klassy'] == _keys ) _dict = { 'Klass' : ['key1', 'key3'], 'Klassy': ['key1', 'key2', 'key3', 'key4']} self.failUnless( i.dict() == _dict )