ATLAS Offline Software
Loading...
Searching...
No Matches
python.Dso Namespace Reference

Classes

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

Functions

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

Variables

str __version__ = "$Revision: 1.12 $"
str __author__ = "Sebastien Binet <binet@cern.ch>"
str __doc__
list __all__
tuple _cpp_builtins
 registry = _Dso.DsoDb()
dict _aliases
 data -------------------------------------------------------------------—
dict _typedefs
 _is_stl_sequence
 _is_stl_mapping
 DsoDb = CxxDsoDb

Function Documentation

◆ _get_native_libname()

_get_native_libname ( libname)
protected

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

helpers

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

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

82def _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()

_is_rootcint_dict ( libname)
protected
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.

141def _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 pat.match(libname) is not None
152

◆ _libName()

_libName ( lib)
protected

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

15def _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()

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

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

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

◆ _to_rootmap_name()

_to_rootmap_name ( typename)
protected
helper method to massage a typename into something understandable
by the rootmap files

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

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

◆ find_library()

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.

112def 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
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:179

◆ load_library()

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.

100def 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__

list __all__
private
Initial value:
= [
'registry',
]

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

◆ __author__

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

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

◆ __doc__

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

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

◆ __version__

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

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

◆ _aliases

dict python.Dso._aliases
protected
Initial value:
= {
'ElementLinkInt_p1' : 'ElementLink_p1<unsigned int>',
'basic_string<char>' : 'string',
'std::basic_string<char>' : 'string',
'vector<basic_string<char> >' : 'vector<string>',
'INavigable4MomentumCollection' : 'DataVector<INavigable4Momentum>',
'IParticleContainer' : 'DataVector<IParticle>',
}

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

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

◆ _cpp_builtins

tuple _cpp_builtins
protected

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

◆ _is_stl_mapping

python.Dso._is_stl_mapping
protected
Initial value:
= re.compile (r'std::map<'
r'(?P<TemplateArg1>.*?),\s*?'
r'(?P<TemplateArg2>.*?)'
r',\s*?std::allocator<\2> >')

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

◆ _is_stl_sequence

python.Dso._is_stl_sequence
protected
Initial value:
= re.compile (r'std::(?P<ContType>.*?)'
r'<(?P<TemplateArg>.*?)'
r',\s*?std::allocator<\2> >')

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

◆ _typedefs

dict python.Dso._typedefs
protected
Initial value:
= {
'INavigable4MomentumCollection' : 'DataVector<INavigable4Momentum>',
'IParticleContainer' : 'DataVector<IParticle>',
}

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

◆ DsoDb

python.Dso.DsoDb = CxxDsoDb

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

◆ registry

python.Dso.registry = _Dso.DsoDb()

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