bug 313956: expand installer .exe contents to make complete mar. r=ted.
[gecko.git] / xpcom / analysis / fix-srcrefs.py
blob71449695579c86cf820acbdd9bb6b85a18c4a216
1 #!/usr/bin/env python
3 """
4 Fix references to source files of the form [LOCpath]
5 so that they are relative to a given source directory.
7 Substitute the DOT-generated image map into the document.
8 """
10 import os, sys, re
12 (srcdir, ) = sys.argv[1:]
13 srcdir = os.path.realpath(srcdir)
15 f = re.compile(r'\[LOC(.*?)\]')
17 def replacer(m):
18 file = m.group(1)
19 file = os.path.realpath(file)
20 if not file.startswith(srcdir):
21 raise Exception("File %s doesn't start with %s" % (file, srcdir))
23 file = file[len(srcdir) + 1:]
24 return file
26 s = re.compile(r'\[MAP(.*?)\]')
28 def mapreplace(m):
29 file = m.group(1)
30 c = open(file).read()
31 return c
33 for line in sys.stdin:
34 line = f.sub(replacer, line)
35 line = s.sub(mapreplace, line)
37 sys.stdout.write(line)