summaryrefslogtreecommitdiff
path: root/docs/pycon2010/fileutil.py
blob: 5e754b5a45ce6fe3f39a5326b8faffa05da0ae35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
import glob
import os.path

for fullfilename in glob.glob('/home/cat/proj/cmd2/*.py'):
    (dirpath, fname) = os.path.split(fullfilename)
    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()