diff options
author | ben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2002-03-21 07:22:43 +0000 |
---|---|---|
committer | ben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2002-03-21 07:22:43 +0000 |
commit | 8c37a5bdfdd46d5cfad6e9d67925ddef9ca382bf (patch) | |
tree | 8f19be83962ef31d8ad58429d575c6f17d89c0ea /rdiff-backup/misc/find2dirs | |
parent | 8259a0d8a9ad1396a93cd6320943dc33446ac6ed (diff) | |
download | rdiff-backup-8c37a5bdfdd46d5cfad6e9d67925ddef9ca382bf.tar.gz |
First checkin
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@2 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/misc/find2dirs')
-rwxr-xr-x | rdiff-backup/misc/find2dirs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/rdiff-backup/misc/find2dirs b/rdiff-backup/misc/find2dirs new file mode 100755 index 0000000..9d919d3 --- /dev/null +++ b/rdiff-backup/misc/find2dirs @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +from __future__ import generators +import sys, os, stat + +def usage(): + print "Usage: find2dirs dir1 dir2" + print + print "Given the name of two directories, list all the files in both, one" + print "per line, but don't repeat a file even if it is in both directories" + sys.exit(1) + +def getlist(base, ext = ""): + """Return iterator yielding filenames from directory""" + if ext: yield ext + else: yield "." + + fullname = os.path.join(base, ext) + if stat.S_ISDIR(stat.S_IFMT(os.lstat(fullname)[stat.ST_MODE])): + for subfile in os.listdir(fullname): + for fn in getlist(base, os.path.join(ext, subfile)): yield fn + +def main(dir1, dir2): + d = {} + for fn in getlist(dir1): d[fn] = 1 + for fn in getlist(dir2): d[fn] = 1 + for fn in d.keys(): print fn + +if not len(sys.argv) == 3: usage() +else: main(sys.argv[1], sys.argv[2]) |