Mercurial > hg > config
changeset 809:b3f75f1361c5
minor mostly formatting fixes
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Fri, 28 Oct 2016 17:27:32 -0700 |
parents | 48ea50d346de |
children | 0afeb265da7f |
files | python/walk.py |
diffstat | 1 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/python/walk.py Fri Oct 28 17:10:27 2016 -0700 +++ b/python/walk.py Fri Oct 28 17:27:32 2016 -0700 @@ -1,5 +1,10 @@ #!/usr/bin/env python +""" +illustration of walking a directory structure +""" + +import argparse import os import sys @@ -9,7 +14,10 @@ filenames.extend([os.path.join(dirpath, f) for f in files]) return sorted(filenames) + def main(args=sys.argv[1:]): + """CLI""" + if not args: print "Usage: %s directory [directory] [...]" % os.path.basename(sys.argv[0]) for arg in args: @@ -20,6 +28,6 @@ print os.path.abspath(arg) else: print >> sys.stderr, "'%s' not a file or directory" - + if __name__ == '__main__': main()