# HG changeset patch # User cat@eee # Date 1266524129 18000 # Node ID d34f3e8d895f796d95865d005442c06ad98fa581 # Parent 40cba30b6125d159dd4d8898c70370767e734d4e working out fileutil diff -r 40cba30b6125 -r d34f3e8d895f docs/pycon2010/fileutil.script --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/pycon2010/fileutil.script Thu Feb 18 15:15:29 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)""") +