view python/directories.py @ 915:0bb00763f6d2

update distribute for modern python packaging
author Jeff Hammel <k0scist@gmail.com>
date Mon, 27 May 2024 16:44:09 -0700
parents a8982ae84a9b
children
line wrap: on
line source

#!/usr/bin/env python

"""
ls unique file paths
"""

import optparse
import os
import sys

here = os.path.dirname(os.path.realpath(__file__))

def main(args=sys.argv[1:]):

    usage = '%prog [options]'
    parser = optparse.OptionParser(usage=usage, description=__doc__)
    parser.add_option('--strip', default='? ')
    options, args = parser.parse_args(args)

    _input = sys.stdin.read()
    lines = [i.strip() for i in _input.splitlines()
             if i.strip()]
    lines = [i[len(options.strip):] if i.startswith(options.strip) else i
             for i in lines]
    paths = set([i.split(os.path.sep)[0] for i in lines])
    for i in sorted(paths):
        print i

if __name__ == '__main__':
    main()