annotate 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
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)""")
368
0816cdb5a7db fix quit() in py
cat@eee
parents: 367
diff changeset
13 quit()