annotate docs/pycon2010/fileutil.script @ 367:d34f3e8d895f

working out fileutil
author cat@eee
date Thu, 18 Feb 2010 15:15:29 -0500
parents
children 0816cdb5a7db
rev   line source
367
d34f3e8d895f working out fileutil
cat@eee
parents:
diff changeset
1 import os
d34f3e8d895f working out fileutil
cat@eee
parents:
diff changeset
2 import os.path
d34f3e8d895f working out fileutil
cat@eee
parents:
diff changeset
3
d34f3e8d895f working out fileutil
cat@eee
parents:
diff changeset
4 for (dirpath, dirnames, filenames) in os.walk('/home/cat/proj/sqlpython/sqlpython'):
d34f3e8d895f working out fileutil
cat@eee
parents:
diff changeset
5 for fname in filenames:
d34f3e8d895f working out fileutil
cat@eee
parents:
diff changeset
6 fullfilename = os.path.join(dirpath, fname)
d34f3e8d895f working out fileutil
cat@eee
parents:
diff changeset
7 stats = os.stat(fullfilename)
d34f3e8d895f working out fileutil
cat@eee
parents:
diff changeset
8 binds['path'] = dirpath
d34f3e8d895f working out fileutil
cat@eee
parents:
diff changeset
9 binds['name'] = fname
d34f3e8d895f working out fileutil
cat@eee
parents:
diff changeset
10 binds['bytes'] = stats.st_size
d34f3e8d895f working out fileutil
cat@eee
parents:
diff changeset
11 cmd("""INSERT INTO cat.files (path, name, bytes)
d34f3e8d895f working out fileutil
cat@eee
parents:
diff changeset
12 VALUES (%(path)s, %(name)s, %(bytes)s)""")
d34f3e8d895f working out fileutil
cat@eee
parents:
diff changeset
13