comparison python/directories.py @ 407:a8982ae84a9b

disaster recovery
author Jeff Hammel <jhammel@mozilla.com>
date Sun, 04 Aug 2013 08:55:32 -0700
parents
children
comparison
equal deleted inserted replaced
406:38dd72d72086 407:a8982ae84a9b
1 #!/usr/bin/env python
2
3 """
4 ls unique file paths
5 """
6
7 import optparse
8 import os
9 import sys
10
11 here = os.path.dirname(os.path.realpath(__file__))
12
13 def main(args=sys.argv[1:]):
14
15 usage = '%prog [options]'
16 parser = optparse.OptionParser(usage=usage, description=__doc__)
17 parser.add_option('--strip', default='? ')
18 options, args = parser.parse_args(args)
19
20 _input = sys.stdin.read()
21 lines = [i.strip() for i in _input.splitlines()
22 if i.strip()]
23 lines = [i[len(options.strip):] if i.startswith(options.strip) else i
24 for i in lines]
25 paths = set([i.split(os.path.sep)[0] for i in lines])
26 for i in sorted(paths):
27 print i
28
29 if __name__ == '__main__':
30 main()