| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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