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

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

◆ _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 141 of file Tools/PyUtils/python/Dso.py.

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

◆ _libName()

def python.Dso._libName (   lib)
private

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

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

◆ _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 253 of file Tools/PyUtils/python/Dso.py.

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

◆ _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 216 of file Tools/PyUtils/python/Dso.py.

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

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

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

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

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

Variable Documentation

◆ __all__

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

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

◆ __author__

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

Definition at line 11 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 12 of file Control/AthenaServices/python/Dso.py.

◆ __version__

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

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

◆ _aliases

python.Dso._aliases
private

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

Definition at line 23 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 38 of file Tools/PyUtils/python/Dso.py.

◆ _is_stl_mapping

python.Dso._is_stl_mapping
private

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

◆ _is_stl_sequence

python.Dso._is_stl_sequence
private

Definition at line 70 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 32 of file Tools/PyUtils/python/Dso.py.

◆ DsoDb

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

◆ registry

python.Dso.registry = _Dso.DsoDb()

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

python.Dso.find_library
def find_library(libname)
Definition: Tools/PyUtils/python/Dso.py:112
python.Dso.load_library
def load_library(libname)
Definition: Tools/PyUtils/python/Dso.py:100
python.Dso._to_rootmap_name
def _to_rootmap_name(typename)
Definition: Tools/PyUtils/python/Dso.py:216
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:253
python.Dso._libName
def _libName(lib)
Definition: Tools/PyUtils/python/Dso.py:15
python.Dso._is_rootcint_dict
def _is_rootcint_dict(libname)
Definition: Tools/PyUtils/python/Dso.py:141
python.Dso._get_native_libname
def _get_native_libname(libname)
functions --------------------------------------------------------------—
Definition: Tools/PyUtils/python/Dso.py:82
Trk::split
@ split
Definition: LayerMaterialProperties.h:38