annotate docs/pycon2010/fileutil.py @ 376:32b9137577b8
avoiding 'str doesn't support the buffer api' exception
author |
cat@eee |
date |
Sun, 21 Feb 2010 15:25:22 -0500 |
parents |
e84703583996 |
children |
|
rev |
line source |
370
|
1 import glob
|
367
|
2 import os.path
|
|
3
|
370
|
4 for fullfilename in glob.glob('/home/cat/proj/cmd2/*.py'):
|
371
|
5 (dirpath, fname) = os.path.split(fullfilename)
|
370
|
6 stats = os.stat(fullfilename)
|
|
7 binds['path'] = dirpath
|
|
8 binds['name'] = fname
|
|
9 binds['bytes'] = stats.st_size
|
|
10 cmd("""INSERT INTO cat.files (path, name, bytes)
|
|
11 VALUES (%(path)s, %(name)s, %(bytes)s)""")
|
|
12 quit()
|