| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

DybPython::Util::gputil Namespace Reference


Classes

class  irange
class  PrintLogger

Functions

def reload_
 you need these 4 lines for gp.gbl.stringstream() to work it seems
def docs_
def __repr__
def __str__
def dress_classes
def undress_classes
def hdr_
def print_
def fillStream_
def _control_run
def inhibit_run
def format_

Variables

int _run_inhibit = 1
 _run_original = None

Function Documentation

def DybPython::Util::gputil::reload_ (  ) 

you need these 4 lines for gp.gbl.stringstream() to work it seems

Definition at line 35 of file gputil.py.

00035              :
00036     import sys
00037     reload(sys.modules[__name__])
00038 
00039 
def docs_(kls):

def DybPython::Util::gputil::docs_ (   kls  ) 

Definition at line 40 of file gputil.py.

00040               :
00041     docs = [getattr(kls,d).__doc__  for d in dir(kls)]
00042     return docs
00043 
00044 
def __repr__(self):

def DybPython::Util::gputil::__repr__ (   self  ) 

pretty print a dict of the properties of the object 
    if an __props__ method that returns the dict has been provided by 
    or added to the class  

Definition at line 45 of file gputil.py.

00045                   :
00046     """ pretty print a dict of the properties of the object 
00047         if an __props__ method that returns the dict has been provided by 
00048         or added to the class  
00049     """
00050     if hasattr(self,"__props__"):
00051         return format_(self.__props__())
00052     else:
00053         return "<%s customized __repr__ not available due to lack of __props__ method  >" % self.__class__.__name__ 
00054 
def __str__(self):

def DybPython::Util::gputil::__str__ (   self  ) 

invokes the print or fillstream methods of the object if they have them 
    to see this with newlines honoured use "print obj" rather than "str(obj)"

Definition at line 55 of file gputil.py.

00055                  :
00056     """ invokes the print or fillstream methods of the object if they have them 
00057         to see this with newlines honoured use "print obj" rather than "str(obj)"
00058     """
00059     s = []
00060     s.append( "<%s >" % self.__class__.__name__ )
00061     pr = print_(self)
00062     if pr:
00063         s.append( pr )
00064     fs = fillStream_(self)
00065     if fs:
00066         s.append( fs )
00067     return "\n".join(s)
00068 
00069                                     
def dress_classes( klasses ):

def DybPython::Util::gputil::dress_classes (   klasses  ) 

replace the repr str methods of the classes 

Definition at line 70 of file gputil.py.

00070                             :
00071     """ replace the repr str methods of the classes """
00072     for kln,prp in klasses.items(): 
00073         kls = pc.makeClass(kln)
00074         kls.__props__ = prp
00075         kls.__repr__  = __repr__
00076         kls.__str__   = __str__
00077 
00078 
def undress_classes( klasses ):

def DybPython::Util::gputil::undress_classes (   klasses  ) 

may be unneeded ...
    call the base repr like so 
       object.__repr__(obj)

Definition at line 79 of file gputil.py.

00079                               :
00080     """ may be unneeded ...
00081         call the base repr like so 
00082            object.__repr__(obj)
00083     """
00084     for kln,prp in klasses.items(): 
00085         kls = pc.makeClass(kln)
00086         if hasattr(kls,'__props__'):
00087             del kls.__props__ 
00088         if hasattr(kls,'__repr__'):
00089             del kls.__repr__ 
00090         if hasattr(kls,'__str__'):
00091             del kls.__str__ 
00092     
00093     
00094     
def hdr_(self):

def DybPython::Util::gputil::hdr_ (   self  ) 

how to access the address of the object on the C++ side ?? 

Definition at line 95 of file gputil.py.

00095               :
00096     """ how to access the address of the object on the C++ side ?? """
00097     d = {}
00098     d.update( _class=self.__class__.__name__ )    
00099     return d
00100 
00101 
00102 
class irange(object):

def DybPython::Util::gputil::print_ (   o  ) 

     special handling to call print methods like :
         void GenParticle::print(basic_ostream<char,char_traits<char> >& ostr = std::cout)
      as print is a reserved word in python and as the output goes to a stream 

Definition at line 115 of file gputil.py.

00115              :
00116     """
00117          special handling to call print methods like :
00118              void GenParticle::print(basic_ostream<char,char_traits<char> >& ostr = std::cout)
00119           as print is a reserved word in python and as the output goes to a stream 
00120     """
00121     if hasattr(o,"print"):
00122         ss = gp.gbl.stringstream()
00123         __print = getattr(o, "print")
00124         __print(ss)
00125         return ss.str()
00126     return None
00127 
00128 
def fillStream_(o):    

def DybPython::Util::gputil::fillStream_ (   o  ) 

Definition at line 129 of file gputil.py.

00129                   :    
00130     if hasattr(o,"fillStream"):
00131         ss = gp.gbl.stringstream()
00132         __fillStream = getattr(o, "fillStream")
00133         __fillStream(ss)
00134         return ss.str()
00135     return None
00136 
00137 
00138 
00139 """
00140     this inhibits a number of GaudiPython.AppMgr.run calls (usually one)  
00141     before replacing this member function  
00142     
00143     this allows to import a module that does g.run(n) without invoking the 
00144     run allowing some further condifuration before really starting the run
00145 
00146 """
00147 

def DybPython::Util::gputil::_control_run (   self,
  nevt 
) [private]

this prevents g.run(n) from doing so 

Definition at line 151 of file gputil.py.

00151                            :
00152     """ this prevents g.run(n) from doing so """ 
00153     
00154     assert self.__class__.__name__ == 'AppMgr'
00155     global _run_inhibit
00156     global _run_original
00157     
00158     assert not self.__class__.run == _run_original , "this should never be invoked after the inhibit is lifted "
00159     
00160     if _run_inhibit > 0: 
00161         print "_control_run inhibiting run %s nevt %s _run_inhibit %s " % ( self, nevt, _run_inhibit )
00162         _run_inhibit -= 1
00163     else:
00164         self.__class__.run = _run_original
00165         print "_control_run replace original run %s nevt %s _run_inhibit %s  " % ( self, nevt, _run_inhibit )
00166         self.run(nevt)
00167 
def inhibit_run(n=1):

def DybPython::Util::gputil::inhibit_run (   n = 1  ) 

Definition at line 168 of file gputil.py.

00168                     :
00169 
00170     from GaudiPython import AppMgr 
00171     global _run_original
00172     _run_original = AppMgr.run  
00173     AppMgr.run = _control_run
00174         
00175     global _run_inhibit
00176     _run_inhibit = n
00177     
00178 
def format_(o):

def DybPython::Util::gputil::format_ (   o  ) 

Definition at line 179 of file gputil.py.

00179               :
00180     import pprint
00181     return pprint.pformat(o)
00182 
00183 
class PrintLogger:


Variable Documentation

int DybPython::Util::gputil::_run_inhibit = 1 [static]

Definition at line 148 of file gputil.py.

DybPython::Util::gputil::_run_original = None [static]

Definition at line 149 of file gputil.py.

| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:13:03 2011 for DybPython by doxygen 1.4.7