Public Member Functions | Public Attributes | List of all members
python.larbatch_posix.dcache_file Class Reference

Public Member Functions

def __init__ (self)
 
def __init__ (self, path, mode='r', buf=-1)
 
def __del__ (self)
 
def close (self)
 
def flush (self)
 
def fileno (self)
 
def __next__ (self)
 
def read (self, size=-1)
 
def readline (self, size=-1)
 
def readlines (self, sizehint=-1)
 
def tell (self)
 
def truncate (self)
 
def truncate (self, pos)
 
def write (self, str)
 
def writelines (self, strs)
 

Public Attributes

 path
 
 mode
 
 local_path
 
 local_file
 

Detailed Description

Definition at line 156 of file larbatch_posix.py.

Constructor & Destructor Documentation

def python.larbatch_posix.dcache_file.__init__ (   self)

Definition at line 160 of file larbatch_posix.py.

160  def __init__(self):
161  self.path = '' # Path of file.
162  self.mode = '' # File mode.
163  self.local_path = '' # Path of local copy of file.
164  self.local_file = None # Open File object of local copy of file.
165 
def python.larbatch_posix.dcache_file.__init__ (   self,
  path,
  mode = 'r',
  buf = -1 
)

Definition at line 168 of file larbatch_posix.py.

168  def __init__(self, path, mode='r', buf=-1):
169 
170  self.path = path
171  self.mode = mode
172  if path.startswith('/pnfs/'):
173  self.local_path = str(uuid.uuid4()) + os.path.basename(path)
174  else:
175  self.local_path = path
176 
177  # Fetch copy of file from dCache, if necessary.
178 
179  if path != self.local_path and (mode.find('r') >= 0 or mode.find('a') >= 0):
180  larbatch_utilities.ifdh_cp(path, self.local_path)
181 
182  # Open local copy of file.
183 
184  self.local_file = __builtins__['open'](self.local_path, mode, buf)
185 
static QCString str
def python.larbatch_posix.dcache_file.__del__ (   self)

Definition at line 188 of file larbatch_posix.py.

188  def __del__(self):
189  self.close()
190 

Member Function Documentation

def python.larbatch_posix.dcache_file.__next__ (   self)

Definition at line 227 of file larbatch_posix.py.

def python.larbatch_posix.dcache_file.close (   self)

Definition at line 193 of file larbatch_posix.py.

193  def close(self):
194 
195  if self.local_file and not self.local_file.closed:
196 
197  # Close local copy of file.
198 
199  self.local_file.close()
200 
201  # If the local path and real path are different, do some cleanups.
202 
203  if self.path != self.local_path:
204 
205  # If file was opend for writing, transfer local copy to dCache.
206 
207  if self.mode.find('w') >= 0 or self.mode.find('a') >= 0 or self.mode.find('+') >= 0:
208  larbatch_utilities.ifdh_cp(self.local_path, self.path)
209 
210  # Delete the local copy regardless of whether the file was open for
211  # reading or writing.
212 
213  os.remove(self.local_path)
214 
def python.larbatch_posix.dcache_file.fileno (   self)

Definition at line 222 of file larbatch_posix.py.

222  def fileno(self):
223  return self.local_file.fileno()
224 
def python.larbatch_posix.dcache_file.flush (   self)

Definition at line 217 of file larbatch_posix.py.

217  def flush(self):
218  self.local_file.flush()
219 
def python.larbatch_posix.dcache_file.read (   self,
  size = -1 
)

Definition at line 232 of file larbatch_posix.py.

232  def read(self, size=-1):
233  return self.local_file.read(size)
234 
def python.larbatch_posix.dcache_file.readline (   self,
  size = -1 
)

Definition at line 237 of file larbatch_posix.py.

237  def readline(self, size=-1):
238  return self.local_file.readline(size)
239 
def python.larbatch_posix.dcache_file.readlines (   self,
  sizehint = -1 
)

Definition at line 242 of file larbatch_posix.py.

242  def readlines(self, sizehint=-1):
243  return self.local_file.readlines()
244 
def readlines(self, sizehint=-1)
def python.larbatch_posix.dcache_file.tell (   self)

Definition at line 247 of file larbatch_posix.py.

247  def tell(self):
248  return self.local_file.tell()
249 
def python.larbatch_posix.dcache_file.truncate (   self)

Definition at line 252 of file larbatch_posix.py.

252  def truncate(self):
253  self.local_file.truncate()
254 
def python.larbatch_posix.dcache_file.truncate (   self,
  pos 
)

Definition at line 257 of file larbatch_posix.py.

257  def truncate(self, pos):
258  self.local_file.truncate(pos)
259 
def python.larbatch_posix.dcache_file.write (   self,
  str 
)

Definition at line 262 of file larbatch_posix.py.

262  def write(self, str):
263  self.local_file.write(str)
264 
def python.larbatch_posix.dcache_file.writelines (   self,
  strs 
)

Definition at line 267 of file larbatch_posix.py.

267  def writelines(self, strs):
268  self.local_file.writelines(strs)
269 
270 # Global functions.
271 
272 
273 # Open file
274 

Member Data Documentation

python.larbatch_posix.dcache_file.local_file

Definition at line 164 of file larbatch_posix.py.

python.larbatch_posix.dcache_file.local_path

Definition at line 163 of file larbatch_posix.py.

python.larbatch_posix.dcache_file.mode

Definition at line 162 of file larbatch_posix.py.

python.larbatch_posix.dcache_file.path

Definition at line 161 of file larbatch_posix.py.


The documentation for this class was generated from the following file: