5 from __future__
import print_function
8 A small utility to deal with pickled files.
10 __author__ =
'Juerg Beringer'
11 __version__ =
'$Id: pickleTool.py 216126 2009-09-29 16:12:59Z atlidbs $'
12 __usage__ =
'pickleTool [options] arg1 [arg2]'
15 import sys, pickle, pprint
18 from optparse
import OptionParser
19 parser = OptionParser(usage=__usage__, version=__version__)
20 parser.add_option(
'-c',
'--create', dest=
'create', action=
'store_true', default=
False, help=
'Pickle input file')
21 parser.add_option(
'-p',
'--pretty', dest=
'pretty', action=
'store_true', default=
False, help=
'Pretty-print/write data')
22 (options,args) = parser.parse_args()
26 parser.error(
'missing input or output file')
27 inFile =
open(args[0],
'r')
31 outFile =
open(args[1],
'wb')
32 pickle.dump(object,outFile)
37 parser.error(
'missing input file')
38 inFile =
open(args[0],
'rb')
39 data = pickle.load(inFile)
42 s = pprint.pformat(data)
46 outFile =
open(args[1],
'w')