Mercurial > hg > config
view python/walk.py @ 694:ebca6d85213a
File "/usr/lib/python3/dist-packages/IPython/config/__init__.py", line 16, in <module>
from .application import *
File "/usr/lib/python3/dist-packages/IPython/config/application.py", line 31, in <module>
from IPython.config.configurable import SingletonConfigurable
File "/usr/lib/python3/dist-packages/IPython/config/configurable.py", line 33, in <module>
from IPython.utils.text import indent, wrap_paragraphs
File "/usr/lib/python3/dist-packages/IPython/utils/text.py", line 28, in <module>
from IPython.external.path import path
File "/usr/lib/python3/dist-packages/IPython/external/path/__init__.py", line 2, in <module>
from path import *
File "/home/jhammel/python/path.py", line 25
print root(path)
^
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Wed, 09 Jul 2014 16:26:49 -0700 |
parents | 83928b2f2776 |
children | b3f75f1361c5 |
line wrap: on
line source
#!/usr/bin/env python import os import sys def all_files(directory): filenames = [] for dirpath, dirnames, files in os.walk('/home/jhammel/music'): filenames.extend([os.path.join(dirpath, f) for f in files]) return sorted(filenames) def main(args=sys.argv[1:]): if not args: print "Usage: %s directory [directory] [...]" % os.path.basename(sys.argv[0]) for arg in args: if os.path.isdir(arg): for i in all_files(arg): print i elif os.path.isfile(arg): print os.path.abspath(arg) else: print >> sys.stderr, "'%s' not a file or directory" if __name__ == '__main__': main()