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

Classes

class  CxxDsoDb
 
class  DsoDb
 
class  PyDsoDb
 
class  RflxEnums
 classes ----------------------------------------------------------------— More...
 

Functions

def _libName (lib)
 
def _get_native_libname (libname)
 functions --------------------------------------------------------------— More...
 
def load_library (libname)
 
def find_library (libname)
 
def _is_rootcint_dict (libname)
 
def _to_rootmap_name (typename)
 
def _to_rflx_name (typename)
 

Variables

string __version__ = "$Revision: 1.12 $"
 
string __author__ = "Sebastien Binet <binet@cern.ch>"
 
string __doc__
 
list __all__
 
 registry = _Dso.DsoDb()
 
 _aliases
 data -------------------------------------------------------------------— More...
 
 _typedefs
 FIXME: in waiting for a proper registration of typedefs in genreflex... More...
 
 _cpp_builtins
 FIXME: in waiting for a proper registration of typedefs in genreflex... More...
 
 _is_stl_sequence
 
 _is_stl_mapping
 
 DsoDb
 

Function Documentation

◆ _get_native_libname()

def python.Dso._get_native_libname (   libname)
private

functions --------------------------------------------------------------—

helpers

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

Definition at line 84 of file Tools/PyUtils/python/Dso.py.

84 def _get_native_libname(libname):
85  """ return the OS-native name from an OS-indenpendent one """
86  plat = sys.platform
87  if plat.count('linux')>0:
88  lib_prefix,lib_suffix = 'lib', '.so'
89  elif plat == 'win32':
90  lib_prefix,lib_suffix = '', '.dll'
91  elif plat == 'darwin':
92  lib_prefix,lib_suffix = 'lib','.dylib'
93  else:
94  raise RuntimeError ("sorry platform [%s] is not (yet?) supported"%plat)
95  _sys_libname = libname
96  if not _sys_libname.startswith (lib_prefix):
97  _sys_libname = ''.join([lib_prefix,_sys_libname])
98  if not _sys_libname.endswith (lib_suffix):
99  _sys_libname = ''.join([_sys_libname, lib_suffix])
100  return _sys_libname
101 

◆ _is_rootcint_dict()

def python.Dso._is_rootcint_dict (   libname)
private
helper function to reject rootcint libraries entries from rootmap
files (which appeared w/ ROOT v21/22)
It seems all of them (and on all platforms) are named like:
 vector<char>: vector.dll

Definition at line 143 of file Tools/PyUtils/python/Dso.py.

143 def _is_rootcint_dict (libname):
144  """helper function to reject rootcint libraries entries from rootmap
145  files (which appeared w/ ROOT v21/22)
146  It seems all of them (and on all platforms) are named like:
147  vector<char>: vector.dll
148  """
149  if libname == ".dll": # pathological case...
150  return False
151  pat = re.compile(r'\w*?.dll')
152  return not (libname.startswith("lib")) and \
153  not (pat.match (libname) is None)
154 

◆ _libName()

def python.Dso._libName (   lib)
private

Definition at line 17 of file Tools/PyUtils/python/Dso.py.

17 def _libName(lib):
18  import platform
19  if platform.system() == "Linux":
20  if lib[:3] != "lib": lib = "lib"+lib
21  if lib[-3:] != ".so": lib = lib+".so"
22  return lib
23 

◆ _to_rflx_name()

def python.Dso._to_rflx_name (   typename)
private
helper method to massage a typename into something understandable
by reflex (which doesn't understand the same thing than rootmaps).

Definition at line 255 of file Tools/PyUtils/python/Dso.py.

255 def _to_rflx_name (typename):
256  """helper method to massage a typename into something understandable
257  by reflex (which doesn't understand the same thing than rootmaps).
258  """
259  global _aliases,_typedefs
260  typename = typename.replace(', ',',')
261  # first the easy case: builtins
262  if typename in _cpp_builtins:
263  return typename
264  # known missing typedefs ?
265  if typename in _typedefs.keys():
266  t = _typedefs[typename]
267  return _to_rflx_name(t)
268  # handle default template arguments of STL sequences
269  if _is_stl_sequence.match(typename):
270  # rootmap files do not contain the default template arguments
271  # for STL containers... consistency, again.
272  _m = _is_stl_sequence.match (typename)
273  _m_type = _m.group('TemplateArg')
274  # handle the dreaded 'std::Bla<Foo<d> >
275  _m_type = _to_rflx_name (_m_type.strip())
276  if _m_type.endswith('>'):
277  _m_type += ' '
278  typename = 'std::%s<%s>' % (_m.group('ContType'), _m_type)
279  typename = typename.replace('std::string>',
280  'std::basic_string<char> >')
281  typename = typename.replace('std::string',
282  'std::basic_string<char>')
283  return typename
284 

◆ _to_rootmap_name()

def python.Dso._to_rootmap_name (   typename)
private
helper method to massage a typename into something understandable
by the rootmap files

Definition at line 218 of file Tools/PyUtils/python/Dso.py.

218 def _to_rootmap_name(typename):
219  """
220  helper method to massage a typename into something understandable
221  by the rootmap files
222  """
223  global _aliases
224  typename = typename.replace(', ',',')
225  # first the easy case: builtins
226  if typename in _cpp_builtins:
227  return typename
228  # known missing aliases ?
229  if typename in _aliases.keys():
230  t = _aliases[typename]
231  return _to_rootmap_name(t)
232  # handle default template arguments of STL sequences
233  if _is_stl_sequence.match(typename):
234  # rootmap files do not contain the default template arguments
235  # for STL containers... consistency, again.
236  _m = _is_stl_sequence.match(typename)
237  _m_type = _m.group('TemplateArg')
238  # handle the dreaded 'std::Bla<Foo<d> >
239  _m_type = _to_rootmap_name(_m_type.strip())
240  if _m_type.endswith('>'):
241  _m_type += ' '
242  typename = 'std::%s<%s>' % (_m.group('ContType'),
243  _m_type)
244  # need to massage a bit the typename to match ROOT naming convention
245  typename = typename.replace('std::basic_string<char> ',
246  'string ')
247  typename = typename.replace('std::basic_string<char>',
248  'string')
249  typename = typename.replace('std::', '')
250  typename = typename.replace('> >', '>->')
251  typename = typename.replace(' >', '>')
252  typename = typename.replace('>->', '> >')
253  return typename
254 

◆ find_library()

def python.Dso.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 114 of file Tools/PyUtils/python/Dso.py.

114 def find_library(libname):
115  """
116  Helper function to find the (full)path to a library given its natural name.
117  @return None on failure
118 
119  usage:
120  >>> find_library('AthenaServices')
121  '/afs/cern.ch/.../AtlasCore/[release]/InstallArea/.../libAthenaServices.so
122  """
123  import os
124 
130  _sys_libname = _get_native_libname(libname)
131  # FIXME: REALLY not portable...
132  if os.name != 'posix':
133  raise RuntimeError('sorry OS [%s] is not supported' % os.name)
134 
135  if 'LD_LIBRARY_PATH' in os.environ:
136  for d in os.environ['LD_LIBRARY_PATH'].split(os.pathsep):
137  lib = os.path.join(d, _sys_libname)
138  if os.path.exists(lib):
139  return lib
140  return
141 
142 

◆ load_library()

def python.Dso.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.
usage:
 >>> load_library ('AthenaServices')
 >>> load_library ('AthenaServicesDict')

Definition at line 102 of file Tools/PyUtils/python/Dso.py.

102 def load_library (libname):
103  """
104  Helper method to load a library by its natural name, not the OS-native name.
105  But if the OS-native name is given, it is safely handled too.
106  usage:
107  >>> load_library ('AthenaServices')
108  >>> load_library ('AthenaServicesDict')
109  """
110  _sys_libname = _get_native_libname(libname)
111  import ctypes
112  return ctypes.cdll.LoadLibrary (_sys_libname)
113 

Variable Documentation

◆ __all__

python.Dso.__all__
private
Initial value:
1 = [
2  'registry',
3  ]

Definition at line 18 of file Control/AthenaServices/python/Dso.py.

◆ __author__

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

Definition at line 12 of file Control/AthenaServices/python/Dso.py.

◆ __doc__

string python.Dso.__doc__
private
Initial value:
1 = """\
2 simple interface to the rootmap files to easily locate reflex dictionaries \
3 (and load them)
4 """

Definition at line 13 of file Control/AthenaServices/python/Dso.py.

◆ __version__

string python.Dso.__version__ = "$Revision: 1.12 $"
private

Definition at line 11 of file Control/AthenaServices/python/Dso.py.

◆ _aliases

python.Dso._aliases
private

data -------------------------------------------------------------------—

Definition at line 25 of file Tools/PyUtils/python/Dso.py.

◆ _cpp_builtins

python.Dso._cpp_builtins
private

FIXME: in waiting for a proper registration of typedefs in genreflex...

Definition at line 40 of file Tools/PyUtils/python/Dso.py.

◆ _is_stl_mapping

python.Dso._is_stl_mapping
private

Definition at line 75 of file Tools/PyUtils/python/Dso.py.

◆ _is_stl_sequence

python.Dso._is_stl_sequence
private

Definition at line 72 of file Tools/PyUtils/python/Dso.py.

◆ _typedefs

python.Dso._typedefs
private

FIXME: in waiting for a proper registration of typedefs in genreflex...

Definition at line 34 of file Tools/PyUtils/python/Dso.py.

◆ DsoDb

Definition at line 479 of file Tools/PyUtils/python/Dso.py.

◆ registry

python.Dso.registry = _Dso.DsoDb()

Definition at line 159 of file Control/AthenaServices/python/Dso.py.

python.Dso.find_library
def find_library(libname)
Definition: Tools/PyUtils/python/Dso.py:114
python.Dso.load_library
def load_library(libname)
Definition: Tools/PyUtils/python/Dso.py:102
python.Dso._to_rootmap_name
def _to_rootmap_name(typename)
Definition: Tools/PyUtils/python/Dso.py:218
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.Dso._to_rflx_name
def _to_rflx_name(typename)
Definition: Tools/PyUtils/python/Dso.py:255
python.Dso._libName
def _libName(lib)
Definition: Tools/PyUtils/python/Dso.py:17
python.Dso._is_rootcint_dict
def _is_rootcint_dict(libname)
Definition: Tools/PyUtils/python/Dso.py:143
python.Dso._get_native_libname
def _get_native_libname(libname)
functions --------------------------------------------------------------—
Definition: Tools/PyUtils/python/Dso.py:84
Trk::split
@ split
Definition: LayerMaterialProperties.h:38