Mercurial > python-cmd2
diff docs/pycon2010/pycon2010.rst @ 376:32b9137577b8
avoiding 'str doesn't support the buffer api' exception
author | cat@eee |
---|---|
date | Sun, 21 Feb 2010 15:25:22 -0500 |
parents | 6cc12ad6e616 |
children |
line wrap: on
line diff
--- a/docs/pycon2010/pycon2010.rst Sat Feb 20 09:26:33 2010 -0500 +++ b/docs/pycon2010/pycon2010.rst Sun Feb 21 15:25:22 2010 -0500 @@ -327,6 +327,35 @@ Now ``cmd2``-based; postgreSQL; MySQL +File reporter +============= + +.. class:: huge + + Gather info: Python + + Store: postgresql + + Report: html + +fileutil.py +=========== + +:: + + 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() + sqlpython features ================== @@ -338,16 +367,6 @@ * UNIX: ls, cat, grep * Special output -File reporter -============= - -.. class:: huge - - Gather info: Python - - Store: postgresql - - Report: html Thank you =========