本文整理汇总了Python中Ganga.GPIDev.Lib.GangaList.GangaList.GangaList._setParent方法的典型用法代码示例。如果您正苦于以下问题:Python GangaList._setParent方法的具体用法?Python GangaList._setParent怎么用?Python GangaList._setParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ganga.GPIDev.Lib.GangaList.GangaList.GangaList
的用法示例。
在下文中一共展示了GangaList._setParent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList [as 别名]
# 或者: from Ganga.GPIDev.Lib.GangaList.GangaList.GangaList import _setParent [as 别名]
def __init__(self, files=[], persistency=None, depth=0):
new_files = GangaList()
if isType(files, LHCbDataset):
for this_file in files:
new_files.append(copy.deepcopy(this_file))
elif isType(files, IGangaFile):
new_files.append(copy.deepcopy(this_file))
elif type(files) == type([]):
for this_file in files:
if type(this_file) == type(''):
new_files.append(string_datafile_shortcut_lhcb(this_file, None), False)
elif isType(this_file, IGangaFile):
new_files.append(this_file, False)
else:
new_files.append(strToDataFile(this_file))
elif type(files) == type(''):
new_files.append(string_datafile_shortcut_lhcb(this_file, None), False)
else:
from Ganga.Core.exceptions import GangaException
raise GangaException("Unknown object passed to LHCbDataset constructor!")
new_files._setParent(self)
super(LHCbDataset, self).__init__()
# Feel free to turn this on again for debugging but it's potentially quite expensive
#logger.debug( "Creating dataset with:\n%s" % files )
self.files = new_files
self.persistency = persistency
self.depth = depth
logger.debug("Dataset Created")
示例2: __init__
# 需要导入模块: from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList [as 别名]
# 或者: from Ganga.GPIDev.Lib.GangaList.GangaList.GangaList import _setParent [as 别名]
def __init__(self, files=None, persistency=None, depth=0):
super(LHCbDataset, self).__init__()
if files is None:
files = []
new_files = GangaList()
if isType(files, LHCbDataset):
for this_file in files:
new_files.append(deepcopy(this_file))
elif isType(files, IGangaFile):
new_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 = this_file
else:
new_file = strToDataFile(this_file)
new_list.append(stripProxy(new_file))
stripProxy(new_files)._list = new_list
elif type(files) is str:
new_files.append(string_datafile_shortcut_lhcb(this_file, None), False)
else:
raise GangaException("Unknown object passed to LHCbDataset constructor!")
new_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" % files )
self.files = new_files
logger.debug("Assigned files")
self.persistency = persistency
self.depth = depth
logger.debug("Dataset Created")
示例3: LHCbDataset
# 需要导入模块: from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList [as 别名]
# 或者: from Ganga.GPIDev.Lib.GangaList.GangaList.GangaList import _setParent [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: __set__
# 需要导入模块: from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList [as 别名]
# 或者: from Ganga.GPIDev.Lib.GangaList.GangaList.GangaList import _setParent [as 别名]
def __set__(self, _obj, _val):
obj = stripProxy(_obj)
val = stripProxy(_val)
from Ganga.GPIDev.Lib.GangaList.GangaList import makeGangaList, GangaList
cs = self._bind_method(obj, self._checkset_name)
if cs:
cs(val)
this_filter = self._bind_method(obj, self._filter_name)
if this_filter:
val = this_filter(val)
# LOCKING
obj._getWriteAccess()
# self._check_getter()
item = stripProxy(obj._schema[self._name])
def cloneVal(v):
return self.__cloneVal(v, obj)
obj_reg = obj._getRegistry()
full_reg = obj_reg is not None and hasattr(obj_reg, 'dirty_flush_counter')
### THIS CODE HERE CHANGES THE DIRTY FLUSH COUNTER SUCH THAT GANGALIST OBJECTS ARE WRITTEN TO DISK ATOMICALLY
### THIS COMES WITH A MAJOR PERFORMANCE IMPROVEMENT IN SOME CODE THAT REALLY SHOULDN'T BE SLOW
### Maybe delete this if/when we aren't using XML repo in future as allowing a really dirty repo is probably bad m'kay
## NB Should really tie in the default here to defaults from Core
old_count = 10
if hasattr(val, '__len__') and full_reg:
old_count = obj_reg.dirty_flush_counter
val_len = 2*len(val) + 10
obj_reg.dirty_flush_counter = val_len
obj_len = 1
if len(val) > 0:
bare_val = stripProxy(val)
if hasattr(bare_val, '_schema'):
obj_len = len(stripProxy(bare_val._schema).datadict.keys())
obj_len = obj_len*2
val_len = val_len * obj_len
if item['sequence']:
_preparable = True if item['preparable'] else False
if len(val) == 0:
val = GangaList()
else:
if isType(item, Schema.ComponentItem):
val = makeGangaList(val, cloneVal, parent=obj, preparable=_preparable)
else:
val = makeGangaList(val, parent=obj, preparable=_preparable)
else:
if isType(item, Schema.ComponentItem):
val = cloneVal(val)
if hasattr(val, '_setParent'):
val._setParent(obj)
### RESET DIRTY COUNT
if full_reg:
obj_reg.dirty_flush_counter = old_count
obj._data[self._name] = val
obj._setDirty()
示例5: __atomic_set__
# 需要导入模块: from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList [as 别名]
# 或者: from Ganga.GPIDev.Lib.GangaList.GangaList.GangaList import _setParent [as 别名]
def __atomic_set__(self, _obj, _val):
## self: attribute being changed or Ganga.GPIDev.Base.Objects.Descriptor in which case getName(self) gives the name of the attribute being changed
## _obj: parent class which 'owns' the attribute
## _val: value of the attribute which we're about to set
#if hasattr(_obj, getName(self)):
# if not isinstance(getattr(_obj, getName(self)), GangaObject):
# if type( getattr(_obj, getName(self)) ) == type(_val):
# object.__setattr__(_obj, getName(self), deepcopy(_val))
# return
#
# if not isinstance(_obj, GangaObject) and type(_obj) == type(_val):
# _obj = deepcopy(_val)
# return
obj = _obj
temp_val = _val
from Ganga.GPIDev.Lib.GangaList.GangaList import makeGangaList
if hasattr(obj, '_checkset_name'):
checkSet = self._bind_method(obj, self._checkset_name)
if checkSet is not None:
checkSet(temp_val)
if hasattr(obj, '_filter_name'):
this_filter = self._bind_method(obj, self._filter_name)
if this_filter:
val = this_filter(temp_val)
else:
val = temp_val
else:
val = temp_val
# LOCKING
obj._getWriteAccess()
#self._check_getter()
item = obj._schema[getName(self)]
def cloneVal(v):
GangaList = _getGangaList()
if isinstance(v, (list, tuple, GangaList)):
new_v = GangaList()
for elem in v:
new_v.append(self.__cloneVal(elem, obj))
return new_v
else:
return self.__cloneVal(v, obj)
## If the item has been defined as a sequence great, let's continue!
if item['sequence']:
_preparable = True if item['preparable'] else False
if len(val) == 0:
GangaList = _getGangaList()
new_val = GangaList()
else:
if isinstance(item, Schema.ComponentItem):
new_val = makeGangaList(val, cloneVal, parent=obj, preparable=_preparable)
else:
new_val = makeGangaList(val, parent=obj, preparable=_preparable)
else:
## Else we need to work out what we've got.
if isinstance(item, Schema.ComponentItem):
GangaList = _getGangaList()
if isinstance(val, (list, tuple, GangaList)):
## Can't have a GangaList inside a GangaList easily so lets not
if isinstance(_obj, GangaList):
newListObj = []
else:
newListObj = GangaList()
self.__createNewList(newListObj, val, cloneVal)
#for elem in val:
# newListObj.append(cloneVal(elem))
new_val = newListObj
else:
new_val = cloneVal(val)
else:
new_val = val
pass
#val = deepcopy(val)
if isinstance(new_val, Node):
new_val._setParent(obj)
obj.setNodeAttribute(getName(self), new_val)
obj._setDirty()