source: issm/trunk-jpl/externalpackages/petsc-dev/src/config/BuildSystem/getsplicers.py@ 11896

Last change on this file since 11896 was 11896, checked in by habbalf, 13 years ago

petsc-dev : Petsc development code in external packages. Mercurial updates

  • Property svn:executable set to *
File size: 1.5 KB
Line 
1#!/usr/bin/env python
2#
3# This is absolute crap; we really need to parse the impls and process them
4#
5import user
6
7import os
8import sys
9import re
10import cPickle
11import project
12import RDict
13import commands
14
15
16def getSplicersDir(splicedimpls,dir,names):
17 reg = re.compile('splicer.begin\(([A-Za-z0-9._]*)\)')
18
19 if 'SCCS' in names: del names[names.index('SCCS')]
20 if 'BitKeeper' in names: del names[names.index('BitKeeper')]
21 if 'docs' in names: del names[names.index('docs')]
22 for f in names:
23 ext = os.path.splitext(f)[1]
24 if not ext in splicedimpls: continue
25 if f == '__init__.py': continue
26 if not os.path.isfile(os.path.join(dir,f)): continue
27 fd = open(os.path.join(dir,f),'r')
28 line = fd.readline()
29 while line:
30 if not line.find('splicer.begin') == -1:
31 fl = reg.search(line)
32 name = fl.group(1)
33
34 line = fd.readline()
35 body = ''
36 while line.find('splicer.end') == -1:
37 body = body + line
38 line = fd.readline()
39 splicedimpls[ext][name] = body
40
41 line = fd.readline()
42 fd.close()
43
44def getSplicers(directories):
45 splicedimpls = {'.c' : {}, '.h' : {}, '.cc' : {}, '.hh' : {}, '.py' : {}, '.m' : {}}
46
47 if not directories: directories = [os.getcwd()]
48 for directory in directories:
49 os.path.walk(directory,getSplicersDir,splicedimpls)
50
51 f = open('splicerblocks', 'w')
52 cPickle.dump(splicedimpls,f)
53 f.close()
54
55if __name__ == '__main__':
56 if len(sys.argv) > 2: sys.exit('Usage: getsplicers.py <directory>')
57 getSplicers(sys.argv[1:-1])
58
Note: See TracBrowser for help on using the repository browser.