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 |
def DybPython::Util::gputil::reload_ | ( | ) |
def DybPython::Util::gputil::docs_ | ( | kls | ) |
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 | ) |
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 |
) |
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:
int DybPython::Util::gputil::_run_inhibit = 1 [static] |
DybPython::Util::gputil::_run_original = None [static] |