-
Notifications
You must be signed in to change notification settings - Fork 0
/
diff_cdat.py
executable file
·51 lines (37 loc) · 1.29 KB
/
diff_cdat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python
"""
Run diff to compare cdat_lite source with a full CDAT source tree.
usage: diff_cdat.py <CDAT_SRC_PATH> [<TAG>]
"""
import sys, os, subprocess
packages = ['cdms2', 'cdutil', 'ncml', 'regrid2', 'xmgrace',
'cdtime', 'genutil', 'Properties', 'unidata']
def diff_package(pkg, name, cdat_path, exclude, tag=None):
if tag is None:
tagstr = ''
else:
tagstr = '-%s' % tag
cdat_pkg = os.path.join(cdat_path, pkg)
patch = '%s%s.patch' % (name, tagstr)
exclude_args = reduce(list.__add__, (['-x', "'%s'" % x] for x in exclude))
cmd = ['diff', '-Nru'] + exclude_args + [pkg, cdat_pkg]
print ' '.join(cmd)
p = subprocess.Popen(' '.join(cmd), stdout=subprocess.PIPE, shell=True)
out = open(patch, 'w')
for line in p.stdout:
out.write(line)
def main(argv=sys.argv[1:]):
cdat_path = argv[0]
if len(argv) > 1:
tag = argv[1]
else:
tag = None
diff_package('libcdms', 'libcdms', cdat_path,
exclude=['.svn', 'config.*', 'cdunifpp*', 'Makefile'],
tag=tag)
for pkg in packages:
diff_package('Packages/%s' % pkg, pkg, cdat_path,
exclude=['.svn', 'build'],
tag=tag)
if __name__ == '__main__':
main()