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

Classes

class  ModuleFacade
 

Functions

def _get_native_libname (libname)
 helpers More...
 
def load_library (libname)
 
def find_library (libname)
 
def reload_module (modname)
 
def py_reload (*args)
 

Variables

string __doc__ = """Module containing a set of Python base classes for PyAthena"""
 
string __author__ = "Sebastien Binet <binet@cern.ch>"
 
list __all__ = []
 data More...
 
list __pseudo_all__
 
 modname = arg.im_self.__class__.__module__
 print (" ==> moduletype") More...
 
 module = reload (sys.modules[modname])
 
 obj = arg.im_self
 
 klass = getattr (module, obj.__class__.__name__)
 
 fct_name = arg.im_func.__name__
 
 new_fct = getattr (klass, fct_name)
 
 cfg_methods = dir(Configurable)
 
tuple d
 
 v = getattr (klass, k)
 

Function Documentation

◆ _get_native_libname()

def python.PyAthena._get_native_libname (   libname)
private

helpers

return the OS-native name from an OS-indenpendent one 

Definition at line 23 of file PyAthena.py.

23 def _get_native_libname(libname):
24  """ return the OS-native name from an OS-indenpendent one """
25  import sys
26  plat = sys.platform
27  if plat.count('linux')>0:
28  lib_prefix,lib_suffix = 'lib', '.so'
29  elif plat == 'win32':
30  lib_prefix,lib_suffix = '', '.dll'
31  elif plat == 'darwin':
32  lib_prefix,lib_suffix = 'lib','.dylib'
33  else:
34  raise RuntimeError ("sorry platform [%s] is not (yet?) supported"%plat)
35  _sys_libname = libname
36  if not _sys_libname.startswith (lib_prefix):
37  _sys_libname = ''.join([lib_prefix,_sys_libname])
38  if not _sys_libname.endswith (lib_suffix):
39  _sys_libname = ''.join([_sys_libname, lib_suffix])
40  return _sys_libname
41 

◆ find_library()

def python.PyAthena.find_library (   libname)
Helper function to find the (full)path to a library given its natural name.
 @return None on failure
 
usage:
 >>> find_library('AthenaServices')
 '/afs/cern.ch/.../AtlasCore/[release]/InstallArea/.../libAthenaServices.so

Definition at line 60 of file PyAthena.py.

60 def find_library(libname):
61  """
62  Helper function to find the (full)path to a library given its natural name.
63  @return None on failure
64 
65  usage:
66  >>> find_library('AthenaServices')
67  '/afs/cern.ch/.../AtlasCore/[release]/InstallArea/.../libAthenaServices.so
68  """
69  import os
70 
76  _sys_libname = _get_native_libname(libname)
77  # FIXME: REALLY not portable...
78  if os.name != 'posix':
79  raise RuntimeError('sorry OS [%s] is not supported' % os.name)
80 
81  if 'LD_LIBRARY_PATH' in os.environ:
82  for d in os.environ['LD_LIBRARY_PATH'].split(os.pathsep):
83  lib = os.path.join(d, _sys_libname)
84  if os.path.exists(lib):
85  return lib
86  return
87 

◆ load_library()

def python.PyAthena.load_library (   libname)
Helper method to load a library by its natural name, not the OS-native name.
But if the OS-native name is given, it is safely handled too. Note that there's
a problem on MacOSX, for which the OS-native name ends with .dylib, but for
which ATLAS builds .so libraries. Override the OS-native name (which should probably
be replaced by two attempts; one with the .dylib and the other with .so)
usage:
 >>> load_library ('AthenaServices')
 >>> load_library ('AthenaServicesDict')

Definition at line 42 of file PyAthena.py.

42 def load_library (libname):
43  """
44  Helper method to load a library by its natural name, not the OS-native name.
45  But if the OS-native name is given, it is safely handled too. Note that there's
46  a problem on MacOSX, for which the OS-native name ends with .dylib, but for
47  which ATLAS builds .so libraries. Override the OS-native name (which should probably
48  be replaced by two attempts; one with the .dylib and the other with .so)
49  usage:
50  >>> load_library ('AthenaServices')
51  >>> load_library ('AthenaServicesDict')
52  """
53  _sys_libname = _get_native_libname(libname)
54  from sys import platform
55  if platform == 'darwin':
56  _sys_libname = _sys_libname.replace('.dylib', '.so')
57  import ctypes
58  return ctypes.cdll.LoadLibrary (_sys_libname)
59 

◆ py_reload()

def python.PyAthena.py_reload ( args)
simple minded function to reload objects, methods and modules

example of usage:
>>> # edit and modify the execute methods of some PyAthena.Alg
... # class, then load back that definition
>>> PyAthena.py_reload (alg1.execute, alg2.execute)
>>> PyAthena.py_reload (alg1.execute)
>>> alg1.execute() # will use the new definition
>>> theApp.nextEvent() # will also use the new definitions
... # of both alg1 and alg2

Definition at line 106 of file PyAthena.py.

106 def py_reload (*args):
107  """simple minded function to reload objects, methods and modules
108 
109  example of usage:
110  >>> # edit and modify the execute methods of some PyAthena.Alg
111  ... # class, then load back that definition
112  >>> PyAthena.py_reload (alg1.execute, alg2.execute)
113  >>> PyAthena.py_reload (alg1.execute)
114  >>> alg1.execute() # will use the new definition
115  >>> theApp.nextEvent() # will also use the new definitions
116  ... # of both alg1 and alg2
117  """
118  import types, sys
119  from importlib import reload
120  for i,arg in enumerate(args):
121  if isinstance (arg, types.ModuleType):

◆ reload_module()

def python.PyAthena.reload_module (   modname)
Helper method to reload a python module by name.
This is useful in the usual following case:
 >>> from Foo import MyAlg
 >>> assert (not 'Foo' in dir())
 >>> reload(Foo) # won't work
 >>> PyAthena.reload_module ('Foo') # will work
 >>> PyAthena.reload_module (Foo)   # will work too

Definition at line 88 of file PyAthena.py.

88 def reload_module (modname):
89  """
90  Helper method to reload a python module by name.
91  This is useful in the usual following case:
92  >>> from Foo import MyAlg
93  >>> assert (not 'Foo' in dir())
94  >>> reload(Foo) # won't work
95  >>> PyAthena.reload_module ('Foo') # will work
96  >>> PyAthena.reload_module (Foo) # will work too
97  """
98  import sys, types
99  from importlib import reload
100  if isinstance (modname, types.ModuleType):
101  modname = modname.__name__
102  if modname in sys.modules:
103  return reload (sys.modules[modname])
104  raise ValueError('no module [%s] could be found'%modname)
105 

Variable Documentation

◆ __all__

list python.PyAthena.__all__ = []
private

data

Definition at line 11 of file PyAthena.py.

◆ __author__

string python.PyAthena.__author__ = "Sebastien Binet <binet@cern.ch>"
private

Definition at line 8 of file PyAthena.py.

◆ __doc__

string python.PyAthena.__doc__ = """Module containing a set of Python base classes for PyAthena"""
private

Definition at line 7 of file PyAthena.py.

◆ __pseudo_all__

list python.PyAthena.__pseudo_all__
private
Initial value:
1 = [ 'StatusCode',
2  'Alg',
3  'Svc',
4  'AlgTool',
5  'Aud',
6  'AthFilterAlgorithm',
7  'services',
8  'algs'
9  ]

Definition at line 12 of file PyAthena.py.

◆ cfg_methods

python.PyAthena.cfg_methods = dir(Configurable)

Definition at line 149 of file PyAthena.py.

◆ d

tuple python.PyAthena.d
Initial value:
1 = (k for k in dir(klass)
2  if not k.startswith('__') and k not in cfg_methods)

Definition at line 150 of file PyAthena.py.

◆ fct_name

python.PyAthena.fct_name = arg.im_func.__name__

Definition at line 135 of file PyAthena.py.

◆ klass

python.PyAthena.klass = getattr (module, obj.__class__.__name__)

Definition at line 133 of file PyAthena.py.

◆ modname

python.PyAthena.modname = arg.im_self.__class__.__module__

print (" ==> moduletype")

print ("-->fct:",new_fct.im_func)

print (" ==> methodtype") reload module holding the class' definition

print (" ==> classtype") reload module holding the class' definition

Definition at line 130 of file PyAthena.py.

◆ module

python.PyAthena.module = reload (sys.modules[modname])

Definition at line 131 of file PyAthena.py.

◆ new_fct

python.PyAthena.new_fct = getattr (klass, fct_name)

Definition at line 136 of file PyAthena.py.

◆ obj

python.PyAthena.obj = arg.im_self

Definition at line 132 of file PyAthena.py.

◆ v

python.PyAthena.v = getattr (klass, k)

Definition at line 154 of file PyAthena.py.

python.PyAthena._get_native_libname
def _get_native_libname(libname)
helpers
Definition: PyAthena.py:23
python.PyAthena.find_library
def find_library(libname)
Definition: PyAthena.py:60
python.PyAthena.load_library
def load_library(libname)
Definition: PyAthena.py:42
beamspotman.dir
string dir
Definition: beamspotman.py:623
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.PyAthena.py_reload
def py_reload(*args)
Definition: PyAthena.py:106
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
python.PyAthena.reload_module
def reload_module(modname)
Definition: PyAthena.py:88