Mercurial > python-cmd2
diff docs/pycon2010/fileutil.py @ 369:bc4b956d57b6
added run to py
author | cat@eee |
---|---|
date | Thu, 18 Feb 2010 16:13:10 -0500 |
parents | docs/pycon2010/fileutil.script@0816cdb5a7db |
children | cd25e114fbc1 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/pycon2010/fileutil.py Thu Feb 18 16:13:10 2010 -0500 @@ -0,0 +1,13 @@ +import os +import os.path + +for (dirpath, dirnames, filenames) in os.walk('/home/cat/proj/sqlpython/sqlpython'): + for fname in filenames: + fullfilename = os.path.join(dirpath, fname) + stats = os.stat(fullfilename) + binds['path'] = dirpath + binds['name'] = fname + binds['bytes'] = stats.st_size + cmd("""INSERT INTO cat.files (path, name, bytes) + VALUES (%(path)s, %(name)s, %(bytes)s)""") + quit()