本文整理汇总了Python中Ganga.GPIDev.Lib.GangaList.GangaList.GangaList.extend方法的典型用法代码示例。如果您正苦于以下问题:Python GangaList.extend方法的具体用法?Python GangaList.extend怎么用?Python GangaList.extend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ganga.GPIDev.Lib.GangaList.GangaList.GangaList
的用法示例。
在下文中一共展示了GangaList.extend方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: expandWildCards
# 需要导入模块: from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList [as 别名]
# 或者: from Ganga.GPIDev.Lib.GangaList.GangaList.GangaList import extend [as 别名]
def expandWildCards(filelist):
"""
"""
l = GangaList()
l.extend(iexpandWildCards(filelist))
return l
示例2: getDiracFiles
# 需要导入模块: from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList [as 别名]
# 或者: from Ganga.GPIDev.Lib.GangaList.GangaList.GangaList import extend [as 别名]
def getDiracFiles():
import os
from GangaDirac.Lib.Files.DiracFile import DiracFile
from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList
filename = DiracFile.diracLFNBase().replace('/', '-') + '.lfns'
logger.info('Creating list, this can take a while if you have a large number of SE files, please wait...')
execute('dirac-dms-user-lfns &> /dev/null', shell=True, timeout=None)
g = GangaList()
with open(filename[1:], 'r') as lfnlist:
lfnlist.seek(0)
g.extend((DiracFile(lfn='%s' % lfn.strip()) for lfn in lfnlist.readlines()))
return addProxy(g)
示例3: LHCbDataset
# 需要导入模块: from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList [as 别名]
# 或者: from Ganga.GPIDev.Lib.GangaList.GangaList.GangaList import extend [as 别名]
class LHCbDataset(GangaDataset):
'''Class for handling LHCb data sets (i.e. inputdata for LHCb jobs).
Example Usage:
ds = LHCbDataset(["lfn:/some/lfn.file","pfn:/some/pfn.file"])
ds[0] # DiracFile("/some/lfn.file") - see DiracFile docs for usage
ds[1] # PhysicalFile("/some/pfn.file")- see PhysicalFile docs for usage
len(ds) # 2 (number of files)
ds.getReplicas() # returns replicas for *all* files in the data set
ds.replicate("CERN-USER") # replicate *all* LFNs to "CERN-USER" SE
ds.getCatalog() # returns XML catalog slice
ds.optionsString() # returns Gaudi-sytle options
[...etc...]
'''
schema = {}
docstr = 'List of PhysicalFile and DiracFile objects'
schema['files'] = GangaFileItem(defvalue=[], typelist=['str', 'Ganga.GPIDev.Adapters.IGangaFile.IGangaFile'], sequence=1, doc=docstr)
docstr = 'Ancestor depth to be queried from the Bookkeeping'
schema['depth'] = SimpleItem(defvalue=0, doc=docstr)
docstr = 'Use contents of file rather than generating catalog.'
schema['XMLCatalogueSlice'] = GangaFileItem(defvalue=None, doc=docstr)
docstr = 'Specify the dataset persistency technology'
schema['persistency'] = SimpleItem(
defvalue=None, typelist=['str', 'type(None)'], doc=docstr)
schema['treat_as_inputfiles'] = SimpleItem(defvalue=False, doc="Treat the inputdata as inputfiles, i.e. copy the inputdata to the WN")
_schema = Schema(Version(3, 0), schema)
_category = 'datasets'
_name = "LHCbDataset"
_exportmethods = ['getReplicas', '__len__', '__getitem__', 'replicate',
'hasLFNs', 'append', 'extend', 'getCatalog', 'optionsString',
'getLFNs', 'getFileNames', 'getFullFileNames',
'difference', 'isSubset', 'isSuperset', 'intersection',
'symmetricDifference', 'union', 'bkMetadata',
'isEmpty', 'hasPFNs', 'getPFNs'] # ,'pop']
def __init__(self, files=None, persistency=None, depth=0, fromRef=False):
super(LHCbDataset, self).__init__()
if files is None:
files = []
self.files = GangaList()
process_files = True
if fromRef:
self.files._list.extend(files)
process_files = False
elif isinstance(files, GangaList):
def isFileTest(_file):
return isinstance(_file, IGangaFile)
areFiles = all([isFileTest(f) for f in files._list])
if areFiles:
self.files._list.extend(files._list)
process_files = False
elif isinstance(files, LHCbDataset):
self.files._list.extend(files.files._list)
process_files = False
if process_files:
if isType(files, LHCbDataset):
for this_file in files:
self.files.append(deepcopy(this_file))
elif isType(files, IGangaFile):
self.files.append(deepcopy(this_file))
elif isType(files, (list, tuple, GangaList)):
new_list = []
for this_file in files:
if type(this_file) is str:
new_file = string_datafile_shortcut_lhcb(this_file, None)
elif isType(this_file, IGangaFile):
new_file = stripProxy(this_file)
else:
new_file = strToDataFile(this_file)
new_list.append(new_file)
self.files.extend(new_list)
elif type(files) is str:
self.files.append(string_datafile_shortcut_lhcb(this_file, None), False)
else:
raise GangaException("Unknown object passed to LHCbDataset constructor!")
self.files._setParent(self)
logger.debug("Processed inputs, assigning files")
# Feel free to turn this on again for debugging but it's potentially quite expensive
#logger.debug( "Creating dataset with:\n%s" % self.files )
logger.debug("Assigned files")
self.persistency = persistency
self.depth = depth
logger.debug("Dataset Created")
def __getitem__(self, i):
'''Proivdes scripting (e.g. ds[2] returns the 3rd file) '''
#this_file = self.files[i]
# print type(this_file)
# return this_file
# return this_file
# return this_file
if type(i) == type(slice(0)):
#.........这里部分代码省略.........
示例4: TestGangaList
# 需要导入模块: from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList [as 别名]
# 或者: from Ganga.GPIDev.Lib.GangaList.GangaList.GangaList import extend [as 别名]
class TestGangaList(GangaGPITestCase):
def __init__(self):
self.ganga_list = None
self.plain1 = []
self.plain2 = []
self.proxied1 = []
self.proxied2 = []
def _makeRandomString(self):
str_len = random.randint(3, 10)
s = ''
for _ in range(str_len):
s += random.choice(string.ascii_letters)
return s
def _makeRandomTFile(self):
name = self._makeRandomString()
subdir = self._makeRandomString()
return TFile(name=name, subdir=subdir)
def setUp(self):
self.ganga_list = GangaList()
self.plain1 = [self._makeRandomTFile() for _ in range(15)]
self.plain2 = [self._makeRandomTFile() for _ in range(10)]
self.proxied1 = GangaList()
self.proxied1.extend(self.plain1[:])
self.proxied2 = GangaList()
self.proxied2.extend(self.plain2[:])
assert len(getProxyAttr(self.proxied1, '_list')) == len(
self.plain1), 'Somthings wrong with construction'
assert len(getProxyAttr(self.proxied2, '_list')) == len(
self.plain2), 'Somthings wrong with construction'
def testAllListMethodsExported(self):
"""Tests that all methods on list are exposed by GangaList"""
def getmethods(_obj):
# get all the method names for an object
return dir(_obj)
list_methods = getmethods([])
gangalist_methods = getmethods(self.ganga_list)
missing_methods = []
for m in list_methods:
if not m in gangalist_methods:
missing_methods.append(m)
if missing_methods:
logger.info(missing_methods)
assert not missing_methods, \
'Not all of lists methods are implemented: %s' % str(
missing_methods)
def testEq(self):
"""Tests the equality op that the rest of the tests rely on."""
assert self.proxied1 == self.plain1, 'Proxied and non-proxied versions should be the same'
def testNq(self):
assert self.proxied1 != None
assert not self.proxied1 != self.proxied1, 'Lists are the same'
assert self.proxied1 != self.proxied2, 'Lists are different'
assert self.plain1 != self.proxied2, 'Lists are different'
def testNonZero(self):
"""@ExpectedFailure"""
assert not GangaList(
), 'An empty GangaList should be false, just like a list'
def testAdd(self):
"""Test __add__"""
assert (self.plain1 + self.plain2) == (self.proxied1 + self.proxied2)
assert isProxy(self.proxied1 + self.proxied2)
def testAddMixed(self):
"""Test __add__ with mixed lists and GangaLists"""
assert (self.plain1 + self.plain2) == (self.proxied1 + self.plain2)
assert (self.plain2 + self.plain1) == (self.plain2 + self.proxied1)
assert isProxy(self.proxied1 + self.plain2)
assert (self.plain2 + self.plain1) == (self.plain2 + self.proxied1)
assert (self.plain1 + self.plain2) == (self.plain1 + self.proxied2)
assert isinstance(self.plain1 + self.proxied2, list)
def testAddMixed2(self):
self.plain1 = range(10)
self.plain2 = range(10)
assert isProxy(self.proxied2[-1]), 'Element access must get proxies'
assert not isProxy(self.plain1[0]), 'Element access must not proxies'
assert isProxy(
#.........这里部分代码省略.........
示例5: TestGangaList
# 需要导入模块: from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList [as 别名]
# 或者: from Ganga.GPIDev.Lib.GangaList.GangaList.GangaList import extend [as 别名]
class TestGangaList(unittest.TestCase):
def __init__(self, *args, **kwargs):
super(TestGangaList, self).__init__(*args, **kwargs)
self.plain1 = []
self.plain2 = []
self.proxied1 = []
self.proxied2 = []
self.ganga_list = GangaList()
@staticmethod
def _makeRandomString():
str_len = random.randint(3, 10)
s = ''
for _ in range(str_len):
s += random.choice(string.ascii_letters)
return s
@staticmethod
def _makeRandomTFile():
name = TestGangaList._makeRandomString()
subdir = TestGangaList._makeRandomString()
return TFile(name=name, subdir=subdir)
def setUp(self):
super(TestGangaList, self).setUp()
self.plain1 = [self._makeRandomTFile() for _ in range(15)]
self.plain2 = [self._makeRandomTFile() for _ in range(10)]
self.proxied1 = GangaList()
self.proxied1.extend(self.plain1[:])
self.proxied2 = GangaList()
self.proxied2.extend(self.plain2[:])
t = TFile()
real_t = stripProxy(t)
new_proxy_t = addProxy(real_t)
#hopefully_t = stripProxy(new_proxy_t)
#assert real_t is hopefully_t
assert t is new_proxy_t
self.assertEqual(len(getProxyAttr(self.proxied1, '_list')), len(self.plain1), "Something's wrong with construction")
self.assertEqual(len(getProxyAttr(self.proxied2, '_list')), len(self.plain2), "Something's wrong with construction")
def testAllListMethodsExported(self):
"""Tests that all methods on list are exposed by GangaList"""
def getmethods(_obj):
# get all the method names for an object
return dir(_obj)
list_methods = getmethods([])
gangalist_methods = getmethods(self.ganga_list)
missing_methods = []
for m in list_methods:
if not m in gangalist_methods:
missing_methods.append(m)
if missing_methods:
logger.info(missing_methods)
self.assertFalse(missing_methods, 'Not all of lists methods are implemented: %s' % missing_methods)
def testEq(self):
"""Tests the equality op that the rest of the tests rely on."""
self.assertEqual(self.proxied1, self.plain1, 'Proxied and non-proxied versions should be the same')
def testNq(self):
self.assertIsNotNone(self.proxied1, None)
self.assertFalse(self.proxied1 != self.proxied1, 'Lists are the same')
self.assertNotEqual(self.proxied1, self.proxied2, 'Lists are different')
self.assertNotEqual(self.plain1, self.proxied2, 'Lists are different')
def testNonZero(self):
"""@ExpectedFailure"""
self.assertFalse(GangaList(), 'An empty GangaList should be false, just like a list')
def testAdd(self):
"""Test __add__"""
self.assertEqual(self.plain1 + self.plain2, self.proxied1 + self.proxied2)
self.assertTrue(isProxy(self.proxied1 + self.proxied2))
def testAddMixed(self):
"""Test __add__ with mixed lists and GangaLists"""
self.assertEqual((self.plain1 + self.plain2), (self.proxied1 + self.plain2))
self.assertEqual((self.plain2 + self.plain1), (self.plain2 + self.proxied1))
self.assertTrue(isProxy(self.proxied1 + self.plain2))
self.assertEqual((self.plain2 + self.plain1), (self.plain2 + self.proxied1))
self.assertEqual((self.plain1 + self.plain2), (self.plain1 + self.proxied2))
self.assertTrue(isinstance(self.plain1 + self.proxied2, list))
def testAddMixed2(self):
self.plain1 = range(10)
#.........这里部分代码省略.........