view docs/pycon2010/fileutil.py @ 370:cd25e114fbc1

shorter fileutil
author cat@eee
date Thu, 18 Feb 2010 16:20:30 -0500
parents bc4b956d57b6
children e84703583996
line wrap: on
line source

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()