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 _protect (s)
 
def _restore (s)
 
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 78 of file root_pickle.py.

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

◆ _protect()

def python.root_pickle._protect (   s)
private

Definition at line 110 of file root_pickle.py.

110  def _protect (s):
111  return s.replace ('\377', '\377\376').replace ('\000', '\377\001')

◆ _restore()

def python.root_pickle._restore (   s)
private

Definition at line 112 of file root_pickle.py.

112  def _restore (s):
113  return s.replace ('\377\001', '\000').replace ('\377\376', '\377')
114 
115 

◆ _setdir()

def python.root_pickle._setdir (   d)
private

Definition at line 87 of file root_pickle.py.

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

◆ 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 461 of file root_pickle.py.

461 def compat_hooks (hooks):
462  """Set compatibility hooks.
463 If this is set, then hooks[0] is called before loading,
464 and hooks[1] is called after loading. hooks[1] is called with
465 the return value of hooks[0] as an argument. This is useful
466 for backwards compatibility in some situations."""
467  global _compat_hooks
468  _compat_hooks = hooks
469  return
470 
471 

◆ dump()

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

Definition at line 472 of file root_pickle.py.

472 def dump (o, f, proto=0, key=None):
473  """Dump object O to the Root TFile F."""
474  return Pickler(f, proto).dump(o, key)
475 

◆ 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 480 of file root_pickle.py.

480 def dump_root (o, fname, proto=0, key=None):
481  """Dump object O to the Root file named FNAME."""
482  f = ROOT.TFile (fname , "RECREATE")
483  dump (o, f, proto, key)
484  f.Close()
485  return
486 

◆ load()

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

Definition at line 476 of file root_pickle.py.

476 def load (f, use_proxy = 1, key=None):
477  """Load an object from the Root TFile F."""
478  return Unpickler(f, use_proxy).load(key)
479 

◆ 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 487 of file root_pickle.py.

487 def load_root (fname, use_proxy = 1, key=None):
488  """Load an object from the Root file named FNAME."""
489  return load (ROOT.TFile (fname), use_proxy, key)
490 
491 

Variable Documentation

◆ _compat_hooks

python.root_pickle._compat_hooks = None
private

Definition at line 335 of file root_pickle.py.

◆ xsave

python.root_pickle.xsave = Saver()

Definition at line 336 of file root_pickle.py.

python.root_pickle.load_root
def load_root(fname, use_proxy=1, key=None)
Definition: root_pickle.py:487
python.root_pickle.dump_root
def dump_root(o, fname, proto=0, key=None)
Definition: root_pickle.py:480
python.root_pickle.compat_hooks
def compat_hooks(hooks)
Definition: root_pickle.py:461
python.root_pickle._protect
def _protect(s)
Definition: root_pickle.py:110
python.root_pickle._setdir
def _setdir(d)
Definition: root_pickle.py:87
python.root_pickle.dump
def dump(o, f, proto=0, key=None)
Definition: root_pickle.py:472
python.root_pickle.load
def load(f, use_proxy=1, key=None)
Definition: root_pickle.py:476
python.root_pickle._restore
def _restore(s)
Definition: root_pickle.py:112
python.root_pickle._getdir
def _getdir()
Definition: root_pickle.py:78