8 from collections
import OrderedDict
11 from CondCore.CondHDF5ESSource.hdf5Writer
import writeH5File
35 self.
_type = dataset.attrs[
'type']
53 self.
_type = group.attrs[
'type']
71 compressorName = self.
_file.attrs[
'default_payload_compressor']
72 if compressorName ==
'lzma':
74 if compressorName ==
'zlib':
80 recordGroup = file[
'Records'][self.
_record]
81 dataProductsGroup = recordGroup[
'DataProducts']
97 idToName = {self.
_file[
'null_payload'].id:
None}
99 idToName.update(d.idToPayloadNames())
101 first = self.
_group[
'first'][()]
102 last = self.
_group[
'last'][()]
103 payloadRefs = self.
_group[
'payload']
106 ([idToName[self.
_file[r].id]
for r
in refs]
for refs
in payloadRefs)) )
113 self.
_file = h5py.File(filename,
'r') 119 recordsGroup = self.
_file[
'Records']
120 for recordName
in recordsGroup:
121 r = recordsGroup[recordName]
122 tagsGroup = r[
'Tags']
123 for tagName
in tagsGroup:
124 tagID2Name[tagsGroup[tagName].id] = tagName
125 globalTagGroup = self.
_file[
'GlobalTags'][self.
_name]
126 return (
H5Tag(self.
_file, self.
_file[t], tagID2Name[self.
_file[t].id])
for t
in globalTagGroup[
'Tags'])
129 parser = argparse.ArgumentParser(description=
'Read from HDF5 file and write to HDF5 file')
130 parser.add_argument(
'input', help=
"Name of file to read")
131 parser.add_argument(
'name', nargs=
'+', help=
"Name of the global tag.")
133 parser.add_argument(
'--exclude',
'-e', nargs=
'*', help =
'list of records to exclude from the file (can not be used with --include)')
134 parser.add_argument(
'--include',
'-i', nargs=
'*', help =
'lost of the only records that should be included in the file (can not be used with --exclude')
135 parser.add_argument(
'--output',
'-o', default=
'test.h5cond', help=
'name of hdf5 output file to write')
136 parser.add_argument(
'--compressor',
'-c', default=
'zlib', choices=[
'zlib',
'lzma',
'none'], help=
"compress data using 'zlib', 'lzma' or 'none'")
137 args = parser.parse_args()
139 if args.exclude
and args.include:
140 print(
"Can not use --exclude and --include at the same time")
143 excludeRecords = set()
145 excludeRecords = set(args.exclude)
146 includeRecords = set()
148 includeRecords = set(args.include)
150 writeH5File(args.output, args.name, excludeRecords, includeRecords,
lambda x:
H5GlobalTag(args.input, x), args.compressor)
151 if __name__ ==
'__main__':
def __init__(self, group, name, compressor)
def iovsNPayloadNames(self)
def writeH5File(fileName, globalTags, excludeRecords, includeRecords, tagReader, compressorName)
def __init__(self, dataset, name, compressor)
def originalTagNames(self)
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
def __init__(self, high, low)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def __init__(self, file, group, name)
def __init__(self, filename, name)
def idToPayloadNames(self)