def readDirectory(dirIn): """Return a list of regular files in directory <dirIn>. If the filename part contains a wildcard, it will be expanded.""" logMuon.info("Reading list of files from directory %s", dirIn) all = [] if FileList.isFileOnCastor(dirIn): all = FileList.nsls(dirIn) elif FileList.hasWildCard(dirIn): # regular files dirname, basename = os.path.split(dirIn) if FileList.hasWildCard(dirname): raise RuntimeError( "Wildcards in directories not supported (filenames only)") from PyUtils import path try: all = path.path(dirname).files(basename) except: logMuon.warning("Could not read files %r from directory %s", basename, dirname) return [] else: from PyUtils import path try: all = path.path(dirIn).files() except: logMuon.warning("Could not read files from directory %s", dirIn) return [] # only return regular files (not directories) return [str(f) for f in all if not FileList.isDirectory(f)]
def load_typeregistry_dso(iname=None): import os import PyUtils.path as _p if iname is None: iname = _p.path(_dflt_typereg_fname) if not iname.exists(): import os projects = os.environ.get('CMTPATH', '').split(os.pathsep)[:2] for project_root in projects: n = _p.path(project_root) / "InstallArea" / "share" / iname if n.exists(): iname = n break else: iname = _p.path(iname) if not iname.exists(): raise OSError('no such file [%s]' % iname) import PyUtils.Logging as _L msg = _L.logging.getLogger("typereg-dso") msg.setLevel(_L.logging.INFO) del _L msg.info("::: loading typeregistry from [%s]...", iname) rflx_names = {} f = iname.open(mode='r') import csv db = csv.reader(f, delimiter=';') for row in db: row = [i.strip() for i in row] root_name = row[0] rflx_name = row[1] rflx_names[root_name] = rflx_name del _p, csv return rflx_names
def load_typeregistry_dso(iname=None): import os import PyUtils.path as _p if iname is None: iname = _p.path(_dflt_typereg_fname) if not iname.exists(): import os projects = os.environ['CMTPATH'].split(os.pathsep)[:2] for project_root in projects: n = _p.path(project_root)/"InstallArea"/"share"/iname if n.exists(): iname = n break else: iname = _p.path(iname) if not iname.exists(): raise OSError('no such file [%s]'%iname) import PyUtils.Logging as _L msg = _L.logging.getLogger("typereg-dso") msg.setLevel(_L.logging.INFO) del _L msg.info("::: loading typeregistry from [%s]...", iname) rflx_names = {} f = iname.open(mode='r') import csv db = csv.reader(f, delimiter=';') for row in db: row = [i.strip() for i in row] root_name = row[0] rflx_name = row[1] rflx_names[root_name] = rflx_name del _p, csv return rflx_names
def gen_typeregistry_dso(oname=_dflt_typereg_fname): '''inspect all the accessible reflex types and get their rootmap-naming. also associate the clid if available. ''' import CLIDComps.clidGenerator as _c cliddb = _c.clidGenerator(db=None) del _c import PyUtils.path as _p oname = _p.path(oname) del _p import PyUtils.Logging as _L msg = _L.logging.getLogger('typereg-dso') msg.setLevel(_L.logging.INFO) #msg.setLevel(_L.logging.VERBOSE) #MN del _L msg.info("installing registry in [%s]...", oname) # FIXME: should use the Cxx one... #reg = DsoDb() reg = PyDsoDb() cls_names = reg.db.keys() import cppyy _load_lib = cppyy.loadDict # if int(cppyy.get_version().split('.')[0]) < 6: if hasattr(cppyy, 'hasCintex'): # load reflex for ROOT ver<6 msg.debug("::: loading reflex") _load_lib('libReflexRflx.so') rflx = cppyy.makeNamespace('Reflex') if not rflx: rflx = cppyy.makeNamespace('ROOT::Reflex') rflx = rflx.Type assert (rflx) def _load_dict(libname, retry=10): msg.debug("::: loading [%s]...", libname) try: return _load_lib(libname) except ( Exception, SystemError, ), err: msg.warning("**error** %s", err) return
def gen_typeregistry_dso(oname=_dflt_typereg_fname): '''inspect all the accessible reflex types and get their rootmap-naming. also associate the clid if available. ''' import CLIDComps.clidGenerator as _c cliddb = _c.clidGenerator(db=None) del _c import PyUtils.path as _p oname = _p.path(oname) del _p import PyUtils.Logging as _L msg = _L.logging.getLogger('typereg-dso') #msg.setLevel(_L.logging.INFO) msg.setLevel(_L.logging.VERBOSE) del _L msg.info("installing registry in [%s]...", oname) # FIXME: should use the Cxx one... #reg = DsoDb() reg = PyDsoDb() cls_names = reg.db.keys() msg.debug("::: loading reflex") import PyCintex PyCintex.Cintex.Enable() PyCintex.loadDict('libReflexRflx.so') rflx = PyCintex.makeNamespace('Reflex') if not rflx: rflx = PyCintex.makeNamespace('ROOT::Reflex') rflx = rflx.Type assert(rflx) import PyCintex _load_lib = PyCintex.loadDict def _load_dict(libname,retry=10): msg.debug("::: loading [%s]...", libname) try: return _load_lib(libname) except (Exception,SystemError,), err: msg.warning("**error** %s", err) return
# @file PyUtils/bin/gen-typereg-dso.py # @purpose a python script to workaround various limitations of rootmap files # and reflex/cint typename impedance mismatches # @author Sebastien Binet <*****@*****.**> # @date February 2009 __doc__ = '''a python script to workaround various limitations of rootmap files and reflex/cint typename impedance mismatches. ''' __version__ = '$Revision: 1.1 $' __author__ = 'Sebastien Binet <*****@*****.**>' if __name__ == "__main__": import sys import os import PyUtils.Dso as Dso oname = 'typereg_dso_db.csv' if len(sys.argv) > 1: oname = sys.argv[1] else: from PyCmt.Cmt import CmtWrapper project_root = CmtWrapper().projects()[0] from PyUtils.path import path oname = path(project_root) / "InstallArea" / "share" / oname if not os.path.exists(oname.dirname()): os.makedirs(oname.dirname()) pass rflx_names = Dso.gen_typeregistry_dso(oname) sys.exit(0)