~ubuntu-branches/ubuntu/saucy/pyqwt3d/saucy-proposed

« back to all changes in this revision

Viewing changes to gendiff

  • Committer: Bazaar Package Importer
  • Author(s): Gudjon I. Gudjonsson
  • Date: 2009-11-07 12:54:42 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20091107125442-92kgp0l7lessmiwo
Tags: 0.1.7~cvs20090625-2
* Change sip4 dependencies to >=4.9
* Add binary dependency on python-sip4 >=4.9
* Bump standards version to 3.8.3, no changes needed
* Add README.source file

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
import difflib
 
4
import os
 
5
import sys
 
6
import time
 
7
 
 
8
def usage():
 
9
    print "gendiff tree .suffix"
 
10
    sys.exit(1)
 
11
 
 
12
# usage()
 
13
 
 
14
def main(args):
 
15
    if len(args) != 3:
 
16
        usage()
 
17
    tree = args[1]
 
18
    suffix = args[2]
 
19
    for root, _, files in os.walk(tree):
 
20
        for name in files:
 
21
            fromfile = os.path.join(root, name)
 
22
            tofile = os.path.join(root, os.path.splitext(name)[0])
 
23
            if os.path.splitext(name)[-1] == suffix and os.path.exists(tofile):
 
24
                fromdate = time.ctime(os.stat(fromfile).st_mtime)
 
25
                todate = time.ctime(os.stat(tofile).st_mtime)
 
26
                fromlines = open(fromfile, 'U').readlines()
 
27
                tolines = open(tofile, 'U').readlines()
 
28
                sys.stdout.writelines(difflib.unified_diff(
 
29
                    fromlines, tolines, fromfile, tofile, fromdate, todate))
 
30
 
 
31
# main()
 
32
 
 
33
if __name__ == '__main__':
 
34
    main(sys.argv)
 
35
 
 
36
 
 
37
# Local Variables: ***
 
38
# mode: python ***
 
39
# End: ***