120def _pythonize_tfile():
121 import cppyy
122 root = import_root()
123 import PyUtils.Helpers as H
124 with H.ShutUp(filters=[
125 re.compile(
126 'TClass::TClass:0: RuntimeWarning: no dictionary for.*'),
127 re.compile(
128 'Warning in <TEnvRec::ChangeValue>: duplicate entry.*'
129 ),
130 ]):
131 cppyy.load_library("libRootUtilsPyROOTDict")
132 _ = root.RootUtils.PyBytes
133
134 read_root_file = root.RootUtils._pythonize_read_root_file
135 tell_root_file = root.RootUtils._pythonize_tell_root_file
136 pass
137 def read(self, size=-1):
138 """read([size]) -> read at most size bytes, returned as a string.
139
140 If the size argument is negative or omitted, read until EOF is reached.
141 Notice that when in non-blocking mode, less data than what was requested
142 may be returned, even if no size parameter was given.
143
144 FIXME: probably doesn't follow python file-like conventions...
145 """
146 SZ = 4096
147
148 if size>=0:
149
150
151 c_buf = read_root_file(self, size)
152 if c_buf and c_buf.sz:
153 v = c_buf.buf
154 return bytes([ord(v[i]) for i in range(v.size())])
155 return ''
156 else:
157 size = SZ
158 out = []
159 while True:
160
161 c_buf = read_root_file(self, size)
162 if c_buf and c_buf.sz:
163 v = c_buf.buf
164 chunk = bytes([ord(v[i]) for i in range(v.size())])
165 out.append(chunk)
166 else:
167 break
168 return b''.join(out)
169
170 root.TFile.read = read
171 del read
172
173 root.TFile.seek = root.TFile.Seek
174 root.TFile.tell = lambda self: tell_root_file(self)
175
181 return
182
183
IovVectorMap_t read(const Folder &theFolder, const SelectionCriterion &choice, const unsigned int limit=10)