| The Gaudi Framework v28r2-patches (bc4ad17a)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

RootMap.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2
3 import os
4 import sys
5
6
7 def _getPath(pathstring = ""):
8 pthlist = []
9 if pathstring == "":
10 if sys.platform == "linux2":
11 pathstring = os.environ["LD_LIBRARY_PATH"]
12 else:
13 pathstring = os.environ["PATH"]
14 pthlist += pathstring.split(os.pathsep)
15 return pthlist
16
17
18 def _getEntry(line):
19 ll=line.split()
20 entry = ll[0]
21 entry=entry.replace("Library.","")
22 entry=entry.replace(":","")
23 entry=entry.replace("@",":")
24 entry=entry.replace("-"," ")
25 lib = ll[1]
26 return entry,lib
27
28 def _getBlock(line):
29 if line.find("Begin"):
30 block=line.split()[-1]
31 return block
32
33
34 def _procRootMap(rtmpfile,rtmapdict):
35 block = ""
36 for line in open(rtmpfile,'r'):
37 line = line[:-1]
38 if line:
39 if line[0] != '#':
40 entry,lib=_getEntry(line)
41 if not rtmapdict.has_key(entry):
42 rtmapdict[entry] = []
43 rtmapdict[entry].append((os.path.join(os.path.dirname(rtmpfile),lib),block))
44 else:
45 block=_getBlock(line)
46
47 def _procSysRootMap(rtmapdict):
48 if os.environ.has_key("ROOTSYS"):
49 rtmpfile = os.path.join(os.environ["ROOTSYS"],"etc","system.rootmap")
50 block = ""
51 for line in open(rtmpfile,'r'):
52 line = line[:-1]
53 if line:
54 if line[0] != '#':
55 entry,lib=_getEntry(line)
56 if not rtmapdict.has_key(entry):
57 rtmapdict[entry] = []
58 rtmapdict[entry].append((os.path.join(os.environ["ROOTSYS"],"lib",lib),block))
59 else:
60 block=_getBlock(line)
61 else:
62 print "WARNING: No ROOTSYS defined!"
63
64 def _isRootMap(filename):
65 # The file must begin with "rootmap"
66 if (filename.find("rootmap")==0) :
67 return True
68 return False
69
70 def getMaps(pathstring = "",sysrtmap=False):
71 rtmapdict = dict()
72 pthlist = _getPath(pathstring)
73 if sysrtmap :
74 _procSysRootMap(rtmapdict)
75 for p in pthlist:
76 try:
77 for f in filter(_isRootMap,os.listdir(p)):
78 rtmpfile = os.path.join(p,f)
79 if (os.path.exists(rtmpfile)):
80 _procRootMap(rtmpfile,rtmapdict)
81 except: pass
82 return rtmapdict
83
84 def _getLongestEntry(maps):
85 sz = 0
86 for k in maps.keys():
87 if len(k)>sz:
88 sz = len(k)
89 return sz
90
91
92 def printMaps(maps,recomp=None):
93 linelen = _getLongestEntry(maps)
94 frmat = r"%-" + str(linelen) + "s\t"
95 kys = maps.keys()
96 kys.sort()
97 if recomp: kys = filter(recomp.search,kys)
98 for k in kys:
99 if len(maps[k])>1:
100 print "!!!!!!!!!!!! WARNING - More than one entry !!!!!!!!!!"
101 for l in maps[k]:
102 print frmat%k,
103 for m in l:
104 print m,
105 print " "
106 return
107
108 def shortPrintMaps(maps,recomp=None):
109 kys = maps.keys()
110 kys.sort()
111 if recomp: kys = filter(recomp.search,kys)
112 for k in kys:
113 if len(maps[k])>1:
114 print k,"!!!!!!!!!!!! WARNING - More than one entry !!!!!!!!!!"
115 else:
116 print k
117 for l in maps[k]:
118 for m in l:
119 print "\t%s"%m,
120 print " "
121 return
122
123 def printKeys(maps,recomp=None):
124 kys = maps.keys()
125 kys.sort()
126 if recomp: kys = filter(recomp.search,kys)
127 for k in kys:
128 if len(maps[k])>1:
129 print "!!!!!!!!!!!! WARNING - More than one entry !!!!!!!!!!"
130 for l in maps[k]:
131 print k
132 return
133
134 def checkDict(maps,recomp=None):
135 kys = maps.keys()
136 kys.sort()
137 if recomp: kys = filter(recomp.search,kys)
138 for k in kys:
139 if len(maps[k])>1:
140 print "!!!!!!!!!!!! WARNING - More than one entry !!!!!!!!!!"
141 print k
142 for l in maps[k]:
143 for m in l:
144 print "\t%s"%m,
145 print " "
146 return
GaudiKernel.RootMap.checkDict
def checkDict(maps, recomp=None)
Definition: RootMap.py:134
GaudiKernel.RootMap.shortPrintMaps
def shortPrintMaps(maps, recomp=None)
Definition: RootMap.py:108
GaudiKernel.RootMap._getPath
def _getPath(pathstring="")
Definition: RootMap.py:7
GaudiKernel.RootMap.getMaps
def getMaps(pathstring="", sysrtmap=False)
Definition: RootMap.py:70
GaudiKernel.RootMap._isRootMap
def _isRootMap(filename)
Definition: RootMap.py:64
GaudiKernel.RootMap._getEntry
def _getEntry(line)
Definition: RootMap.py:18
GaudiKernel.RootMap._getLongestEntry
def _getLongestEntry(maps)
Definition: RootMap.py:84
GaudiKernel.RootMap.printKeys
def printKeys(maps, recomp=None)
Definition: RootMap.py:123
GaudiKernel.RootMap._getBlock
def _getBlock(line)
Definition: RootMap.py:28
GaudiKernel.RootMap._procRootMap
def _procRootMap(rtmpfile, rtmapdict)
Definition: RootMap.py:34
GaudiKernel.RootMap._procSysRootMap
def _procSysRootMap(rtmapdict)
Definition: RootMap.py:47
GaudiKernel.RootMap.printMaps
def printMaps(maps, recomp=None)
Definition: RootMap.py:92