本文整理汇总了Python中WMQuality.Emulators.DataBlockGenerator.DataBlockGenerator.DataBlockGenerator._openForWriting方法的典型用法代码示例。如果您正苦于以下问题:Python DataBlockGenerator._openForWriting方法的具体用法?Python DataBlockGenerator._openForWriting怎么用?Python DataBlockGenerator._openForWriting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WMQuality.Emulators.DataBlockGenerator.DataBlockGenerator.DataBlockGenerator
的用法示例。
在下文中一共展示了DataBlockGenerator._openForWriting方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from WMQuality.Emulators.DataBlockGenerator.DataBlockGenerator import DataBlockGenerator [as 别名]
# 或者: from WMQuality.Emulators.DataBlockGenerator.DataBlockGenerator.DataBlockGenerator import _openForWriting [as 别名]
class DBSReader:
"""
Mock up dbs access
"""
def __init__(self, url, **contact):
self.dataBlocks = DataBlockGenerator()
args = { "url" : url, "level" : 'ERROR', "version" : 'DBS_2_0_9'}
self.dbs = _MockDBSApi(args)
def getFileBlocksInfo(self, dataset, onlyClosedBlocks = True,
blockName = '*', locations = True):
"""Fake block info"""
blocks = [x for x in self.dataBlocks.getBlocks(dataset)
if x['Name'] == blockName or blockName == '*']
if not blocks:
# Weird error handling follows, this is what dbs does:
# If block specified, return [], else raise DbsBadRequest error
if blockName != '*':
return []
else:
raise DBSReaderError('DbsBadRequest: DBS Server Raised An Error')
if locations:
for block in blocks:
block['StorageElementList'] = [{'Role' : '', 'Name' : x} for x in \
self.listFileBlockLocation(block['Name'])]
return blocks
def lfnsInBlock(self, fileBlockName):
"""
_lfnsInBlock_
Get a fake list of LFNs for the block
"""
files = self.listFilesInBlock(fileBlockName)
return [x['LogicalFileName'] for x in files]
def listFileBlocks(self, dataset, onlyClosedBlocks = False,
blockName = '*'):
"""Get fake block names"""
return [x['Name'] for x in self.getFileBlocksInfo(dataset, onlyClosedBlocks = False,
blockName = blockName,
locations = False)]
def listOpenFileBlocks(self, dataset):
"""
_listOpenFileBlocks_
Retrieve a list of open fileblock names for a dataset
"""
return [x['Name'] for x in self.getFileBlocksInfo(dataset, onlyClosedBlocks = False,
locations = False) if str(x['OpenForWriting' ]) == '1']
def listFileBlockLocation(self, block):
"""Fake locations"""
return self.dataBlocks.getLocation(block)
def listFilesInBlock(self, fileBlockName):
"""Fake files"""
return self.dataBlocks.getFiles(fileBlockName)
def listFilesInBlockWithParents(self, block):
return self.dataBlocks.getFiles(block, True)
def getFileBlock(self, block):
"""Return block + locations"""
result = { block : {
"StorageElements" : self.listFileBlockLocation(block),
"Files" : self.listFilesInBlock(block),
"IsOpen" : self.dataBlocks._openForWriting(),
}
}
return result
def getFileBlockWithParents(self, fileBlockName):
"""
_getFileBlockWithParents_
return a dictionary:
{ blockName: {
"StorageElements" : [<se list>],
"Files" : dictionaries representing each file
}
}
files
"""
result = { fileBlockName: {
"StorageElements" : self.listFileBlockLocation(fileBlockName),
"Files" : self.listFilesInBlockWithParents(fileBlockName),
"IsOpen" : self.dataBlocks._openForWriting(),
}
}
return result
#.........这里部分代码省略.........