ATLAS Offline Software
Classes | Functions | Variables
python.root_pickle Namespace Reference

Classes

class  Pickler
 
class  Read_Wrapper
 
class  Root_Proxy
 
class  Saver
 
class  Unpickler
 
class  Write_Wrapper
 

Functions

def _getdir ()
 
def _setdir (d)
 
def compat_hooks (hooks)
 
def dump (o, f, proto=0, key=None)
 
def load (f, use_proxy=1, key=None)
 
def dump_root (o, fname, proto=0, key=None)
 
def load_root (fname, use_proxy=1, key=None)
 

Variables

 _compat_hooks = None
 
 xsave = Saver()
 

Function Documentation

◆ _getdir()

def python.root_pickle._getdir ( )
private

Definition at line 76 of file root_pickle.py.

76 def _getdir():
77  if hasattr (ROOT.TDirectory, 'CurrentDirectory'):
78  d = ROOT.TDirectory.CurrentDirectory()
79  if hasattr (d, 'load'):
80  # Handle case of CurrentDirectory() returning an atomic.
81  d = d.load()
82  return ROOT.gDirectory
83 
84 

◆ _setdir()

def python.root_pickle._setdir (   d)
private

Definition at line 85 of file root_pickle.py.

85 def _setdir (d):
86  ROOT.TDirectory.cd (d)
87 
88 
89 #
90 # This stuff was originally written in terms of an stringIO stream.
91 # But with py3, i couldn't find a better way of getting bytes objects
92 # into and out of a TString.
93 #
94 # Argh! We can't store NULs in TObjStrings.
95 # But pickle protocols > 0 are binary protocols, and will get corrupted
96 # if we truncate at a NUL.
97 # So, when we save the pickle data, make the mappings:
98 # 0x00 -> 0xff 0x01
99 # 0xff -> 0xff 0xfe
100 # ... This may actually be obsolete --- looks like we can have NULs
101 # in TObjString now, if we access the TString direectly. But retain
102 # for compatibility with existing pickles.
103 #
104 

◆ compat_hooks()

def python.root_pickle.compat_hooks (   hooks)
Set compatibility hooks.
If this is set, then hooks[0] is called before loading,
and hooks[1] is called after loading.  hooks[1] is called with
the return value of hooks[0] as an argument.  This is useful
for backwards compatibility in some situations.

Definition at line 415 of file root_pickle.py.

415 def compat_hooks (hooks):
416  """Set compatibility hooks.
417 If this is set, then hooks[0] is called before loading,
418 and hooks[1] is called after loading. hooks[1] is called with
419 the return value of hooks[0] as an argument. This is useful
420 for backwards compatibility in some situations."""
421  global _compat_hooks
422  _compat_hooks = hooks
423  return
424 
425 

◆ dump()

def python.root_pickle.dump (   o,
  f,
  proto = 0,
  key = None 
)
Dump object O to the Root TFile F.

Definition at line 426 of file root_pickle.py.

426 def dump (o, f, proto=0, key=None):
427  """Dump object O to the Root TFile F."""
428  return Pickler(f, proto).dump(o, key)
429 

◆ dump_root()

def python.root_pickle.dump_root (   o,
  fname,
  proto = 0,
  key = None 
)
Dump object O to the Root file named FNAME.

Definition at line 434 of file root_pickle.py.

434 def dump_root (o, fname, proto=0, key=None):
435  """Dump object O to the Root file named FNAME."""
436  f = ROOT.TFile (fname , "RECREATE")
437  dump (o, f, proto, key)
438  f.Close()
439  return
440 

◆ load()

def python.root_pickle.load (   f,
  use_proxy = 1,
  key = None 
)
Load an object from the Root TFile F.

Definition at line 430 of file root_pickle.py.

430 def load (f, use_proxy = 1, key=None):
431  """Load an object from the Root TFile F."""
432  return Unpickler(f, use_proxy).load(key)
433 

◆ load_root()

def python.root_pickle.load_root (   fname,
  use_proxy = 1,
  key = None 
)
Load an object from the Root file named FNAME.

Definition at line 441 of file root_pickle.py.

441 def load_root (fname, use_proxy = 1, key=None):
442  """Load an object from the Root file named FNAME."""
443  return load (ROOT.TFile (fname), use_proxy, key)
444 
445 

Variable Documentation

◆ _compat_hooks

python.root_pickle._compat_hooks = None
private

Definition at line 289 of file root_pickle.py.

◆ xsave

python.root_pickle.xsave = Saver()

Definition at line 290 of file root_pickle.py.

python.root_pickle.load_root
def load_root(fname, use_proxy=1, key=None)
Definition: root_pickle.py:441
python.root_pickle.dump_root
def dump_root(o, fname, proto=0, key=None)
Definition: root_pickle.py:434
python.root_pickle.compat_hooks
def compat_hooks(hooks)
Definition: root_pickle.py:415
python.root_pickle._setdir
def _setdir(d)
Definition: root_pickle.py:85
python.root_pickle.dump
def dump(o, f, proto=0, key=None)
Definition: root_pickle.py:426
python.root_pickle.load
def load(f, use_proxy=1, key=None)
Definition: root_pickle.py:430
python.root_pickle._getdir
def _getdir()
Definition: root_pickle.py:76