mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
* 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)
This commit is contained in:
parent
47db16580a
commit
e2b61e0190
3 changed files with 37 additions and 15 deletions
|
@ -345,6 +345,11 @@ Tools/Demos
|
||||||
|
|
||||||
- The db2pickle and pickle2db scripts can now dump/load gdbm files.
|
- The db2pickle and pickle2db scripts can now dump/load gdbm files.
|
||||||
|
|
||||||
|
- The file order on the command line of the pickle2db script was reversed.
|
||||||
|
It is now [ picklefile ] dbfile. This provides better symmetry with
|
||||||
|
db2pickle. The file arguments to both scripts are now source followed by
|
||||||
|
destination in situations where both files are given.
|
||||||
|
|
||||||
- The pydoc script will display a link to the module documentation for
|
- The pydoc script will display a link to the module documentation for
|
||||||
modules determined to be part of the core distribution. The documentation
|
modules determined to be part of the core distribution. The documentation
|
||||||
base directory defaults to http://www.python.org/doc/current/lib/ but can
|
base directory defaults to http://www.python.org/doc/current/lib/ but can
|
||||||
|
|
|
@ -4,10 +4,18 @@
|
||||||
Synopsis: %(prog)s [-h|-g|-b|-r|-a] dbfile [ picklefile ]
|
Synopsis: %(prog)s [-h|-g|-b|-r|-a] dbfile [ picklefile ]
|
||||||
|
|
||||||
Convert the database file given on the command line to a pickle
|
Convert the database file given on the command line to a pickle
|
||||||
representation. The optional flags indicate the type of the database (hash,
|
representation. The optional flags indicate the type of the database:
|
||||||
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,
|
-a - open using anydbm
|
||||||
the pickle output is written to standard output.
|
-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.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,27 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Synopsis: %(prog)s [-h|-b|-g|-r|-a|-d] dbfile [ picklefile ]
|
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
|
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
|
database. If the database already exists, any contents are deleted. The
|
||||||
optional flags indicate the type of the database (bsddb hash, bsddb btree,
|
optional flags indicate the type of the output database:
|
||||||
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
|
-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
|
hash or btree database using db2pickle.py and reconstitute it to a recno
|
||||||
database with %(prog)s.
|
database with %(prog)s unless your keys are integers.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import getopt
|
import getopt
|
||||||
|
@ -56,15 +65,15 @@ def main(args):
|
||||||
usage()
|
usage()
|
||||||
return 1
|
return 1
|
||||||
elif len(args) == 1:
|
elif len(args) == 1:
|
||||||
dbfile = args[0]
|
|
||||||
pfile = sys.stdin
|
pfile = sys.stdin
|
||||||
else:
|
|
||||||
dbfile = args[0]
|
dbfile = args[0]
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
pfile = open(args[1], 'rb')
|
pfile = open(args[0], 'rb')
|
||||||
except IOError:
|
except IOError:
|
||||||
sys.stderr.write("Unable to open %s\n" % args[1])
|
sys.stderr.write("Unable to open %s\n" % args[0])
|
||||||
return 1
|
return 1
|
||||||
|
dbfile = args[1]
|
||||||
|
|
||||||
dbopen = None
|
dbopen = None
|
||||||
for opt, arg in opts:
|
for opt, arg in opts:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue