annotate docs/pycon2010/fileutil.script @ 368:0816cdb5a7db

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