[Python-checkins] python/dist/src/Tools/scripts db2pickle.py, 1.5,
1.6 pickle2db.py, 1.6, 1.7
montanaro at users.sourceforge.net
montanaro at users.sourceforge.net
Wed Mar 3 12:42:10 EST 2004
Update of /cvsroot/python/python/dist/src/Tools/scripts
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4650/Tools/scripts
Modified Files:
db2pickle.py pickle2db.py
Log Message:
* explain flags in doc strings
* reverse order of files on the command line in pickle2db.py to make it
symmetrical with db2pickle.py in the two-arg case (src, then dest)
Index: db2pickle.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/scripts/db2pickle.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** db2pickle.py 28 Oct 2003 16:17:54 -0000 1.5
--- db2pickle.py 3 Mar 2004 17:42:08 -0000 1.6
***************
*** 5,12 ****
Convert the database file given on the command line to a pickle
! representation. The optional flags indicate the type of the database (hash,
! btree, recno). The default is hash. If a pickle file is named it is opened
! for write access (deleting any existing data). If no pickle file is named,
! the pickle output is written to standard output.
"""
--- 5,20 ----
Convert the database file given on the command line to a pickle
! representation. The optional flags indicate the type of the database:
!
! -a - open using anydbm
! -b - open as bsddb btree file
! -d - open as dbm file
! -g - open as gdbm file
! -h - open as bsddb hash file
! -r - open as bsddb recno file
!
! The default is hash. If a pickle file is named it is opened for write
! access (deleting any existing data). If no pickle file is named, the pickle
! output is written to standard output.
"""
Index: pickle2db.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/scripts/pickle2db.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** pickle2db.py 28 Oct 2003 16:17:54 -0000 1.6
--- pickle2db.py 3 Mar 2004 17:42:08 -0000 1.7
***************
*** 2,17 ****
"""
! Synopsis: %(prog)s [-h|-b|-g|-r|-a|-d] dbfile [ picklefile ]
Read the given picklefile as a series of key/value pairs and write to a new
database. If the database already exists, any contents are deleted. The
! optional flags indicate the type of the database (bsddb hash, bsddb btree,
! bsddb recno, anydbm, dbm). The default is hash. If a pickle file is named
! it is opened for read access. If no pickle file is named, the pickle input
! is read from standard input.
! Note that recno databases can only contain numeric keys, so you can't dump a
hash or btree database using db2pickle.py and reconstitute it to a recno
! database with %(prog)s.
"""
--- 2,26 ----
"""
! Synopsis: %(prog)s [-h|-b|-g|-r|-a|-d] [ picklefile ] dbfile
Read the given picklefile as a series of key/value pairs and write to a new
database. If the database already exists, any contents are deleted. The
! optional flags indicate the type of the output database:
! -a - open using anydbm
! -b - open as bsddb btree file
! -d - open as dbm file
! -g - open as gdbm file
! -h - open as bsddb hash file
! -r - open as bsddb recno file
!
! The default is hash. If a pickle file is named it is opened for read
! access. If no pickle file is named, the pickle input is read from standard
! input.
!
! Note that recno databases can only contain integer keys, so you can't dump a
hash or btree database using db2pickle.py and reconstitute it to a recno
! database with %(prog)s unless your keys are integers.
!
"""
***************
*** 57,69 ****
return 1
elif len(args) == 1:
- dbfile = args[0]
pfile = sys.stdin
- else:
dbfile = args[0]
try:
! pfile = open(args[1], 'rb')
except IOError:
! sys.stderr.write("Unable to open %s\n" % args[1])
return 1
dbopen = None
--- 66,78 ----
return 1
elif len(args) == 1:
pfile = sys.stdin
dbfile = args[0]
+ else:
try:
! pfile = open(args[0], 'rb')
except IOError:
! sys.stderr.write("Unable to open %s\n" % args[0])
return 1
+ dbfile = args[1]
dbopen = None
More information about the Python-checkins
mailing list