| The Gaudi Framework v30r0 (c919700c)

- 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
29 def _getBlock(line):
30 if line.find("Begin"):
31 block = line.split()[-1]
32 return block
33
34
35 def _procRootMap(rtmpfile, rtmapdict):
36 block = ""
37 for line in open(rtmpfile, 'r'):
38 line = line[:-1]
39 if line:
40 if line[0] != '#':
41 entry, lib = _getEntry(line)
42 if not rtmapdict.has_key(entry):
43 rtmapdict[entry] = []
44 rtmapdict[entry].append(
45 (os.path.join(os.path.dirname(rtmpfile), lib), block))
46 else:
47 block = _getBlock(line)
48
49
50 def _procSysRootMap(rtmapdict):
51 if os.environ.has_key("ROOTSYS"):
52 rtmpfile = os.path.join(os.environ["ROOTSYS"], "etc", "system.rootmap")
53 block = ""
54 for line in open(rtmpfile, 'r'):
55 line = line[:-1]
56 if line:
57 if line[0] != '#':
58 entry, lib = _getEntry(line)
59 if not rtmapdict.has_key(entry):
60 rtmapdict[entry] = []
61 rtmapdict[entry].append(
62 (os.path.join(os.environ["ROOTSYS"], "lib", lib), block))
63 else:
64 block = _getBlock(line)
65 else:
66 print "WARNING: No ROOTSYS defined!"
67
68
69 def _isRootMap(filename):
70 # The file must begin with "rootmap"
71 if (filename.find("rootmap") == 0):
72 return True
73 return False
74
75
76 def getMaps(pathstring="", sysrtmap=False):
77 rtmapdict = dict()
78 pthlist = _getPath(pathstring)
79 if sysrtmap:
80 _procSysRootMap(rtmapdict)
81 for p in pthlist:
82 try:
83 for f in filter(_isRootMap, os.listdir(p)):
84 rtmpfile = os.path.join(p, f)
85 if (os.path.exists(rtmpfile)):
86 _procRootMap(rtmpfile, rtmapdict)
87 except:
88 pass
89 return rtmapdict
90
91
92 def _getLongestEntry(maps):
93 sz = 0
94 for k in maps.keys():
95 if len(k) > sz:
96 sz = len(k)
97 return sz
98
99
100 def printMaps(maps, recomp=None):
101 linelen = _getLongestEntry(maps)
102 frmat = r"%-" + str(linelen) + "s\t"
103 kys = maps.keys()
104 kys.sort()
105 if recomp:
106 kys = filter(recomp.search, kys)
107 for k in kys:
108 if len(maps[k]) > 1:
109 print "!!!!!!!!!!!! WARNING - More than one entry !!!!!!!!!!"
110 for l in maps[k]:
111 print frmat % k,
112 for m in l:
113 print m,
114 print " "
115 return
116
117
118 def shortPrintMaps(maps, recomp=None):
119 kys = maps.keys()
120 kys.sort()
121 if recomp:
122 kys = filter(recomp.search, kys)
123 for k in kys:
124 if len(maps[k]) > 1:
125 print k, "!!!!!!!!!!!! WARNING - More than one entry !!!!!!!!!!"
126 else:
127 print k
128 for l in maps[k]:
129 for m in l:
130 print "\t%s" % m,
131 print " "
132 return
133
134
135 def printKeys(maps, recomp=None):
136 kys = maps.keys()
137 kys.sort()
138 if recomp:
139 kys = filter(recomp.search, kys)
140 for k in kys:
141 if len(maps[k]) > 1:
142 print "!!!!!!!!!!!! WARNING - More than one entry !!!!!!!!!!"
143 for l in maps[k]:
144 print k
145 return
146
147
148 def checkDict(maps, recomp=None):
149 kys = maps.keys()
150 kys.sort()
151 if recomp:
152 kys = filter(recomp.search, kys)
153 for k in kys:
154 if len(maps[k]) > 1:
155 print "!!!!!!!!!!!! WARNING - More than one entry !!!!!!!!!!"
156 print k
157 for l in maps[k]:
158 for m in l:
159 print "\t%s" % m,
160 print " "
161 return
GaudiKernel.RootMap.checkDict
def checkDict(maps, recomp=None)
Definition: RootMap.py:148
GaudiKernel.RootMap.shortPrintMaps
def shortPrintMaps(maps, recomp=None)
Definition: RootMap.py:118
GaudiKernel.RootMap._getPath
def _getPath(pathstring="")
Definition: RootMap.py:7
GaudiKernel.RootMap.getMaps
def getMaps(pathstring="", sysrtmap=False)
Definition: RootMap.py:76
GaudiKernel.RootMap._isRootMap
def _isRootMap(filename)
Definition: RootMap.py:69
GaudiKernel.RootMap._getEntry
def _getEntry(line)
Definition: RootMap.py:18
GaudiKernel.RootMap._getLongestEntry
def _getLongestEntry(maps)
Definition: RootMap.py:92
GaudiKernel.RootMap.printKeys
def printKeys(maps, recomp=None)
Definition: RootMap.py:135
GaudiKernel.RootMap._getBlock
def _getBlock(line)
Definition: RootMap.py:29
GaudiKernel.RootMap._procRootMap
def _procRootMap(rtmpfile, rtmapdict)
Definition: RootMap.py:35
GaudiKernel.RootMap._procSysRootMap
def _procSysRootMap(rtmapdict)
Definition: RootMap.py:50
GaudiKernel.RootMap.printMaps
def printMaps(maps, recomp=None)
Definition: RootMap.py:100