Mercurial > python-cmd2
comparison docs/pycon2010/fileutil.py @ 370:cd25e114fbc1
shorter fileutil
author | cat@eee |
---|---|
date | Thu, 18 Feb 2010 16:20:30 -0500 |
parents | bc4b956d57b6 |
children | e84703583996 |
comparison
equal
deleted
inserted
replaced
369:bc4b956d57b6 | 370:cd25e114fbc1 |
---|---|
1 import os | 1 import glob |
2 import os.path | 2 import os.path |
3 | 3 |
4 for (dirpath, dirnames, filenames) in os.walk('/home/cat/proj/sqlpython/sqlpython'): | 4 for fullfilename in glob.glob('/home/cat/proj/cmd2/*.py'): |
5 for fname in filenames: | 5 dirpath, fname) = os.path.split(fullfilename) |
6 fullfilename = os.path.join(dirpath, fname) | 6 stats = os.stat(fullfilename) |
7 stats = os.stat(fullfilename) | 7 binds['path'] = dirpath |
8 binds['path'] = dirpath | 8 binds['name'] = fname |
9 binds['name'] = fname | 9 binds['bytes'] = stats.st_size |
10 binds['bytes'] = stats.st_size | 10 cmd("""INSERT INTO cat.files (path, name, bytes) |
11 cmd("""INSERT INTO cat.files (path, name, bytes) | 11 VALUES (%(path)s, %(name)s, %(bytes)s)""") |
12 VALUES (%(path)s, %(name)s, %(bytes)s)""") | 12 quit() |
13 quit() |