Skip to content

Commit

Permalink
Add script print_pickle.py
Browse files Browse the repository at this point in the history
  • Loading branch information
shuds13 committed Apr 2, 2020
1 parent 86f9a38 commit 6f87ff3
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions postproc_scripts/print_pickle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python
import sys
import pickle
from pprint import pprint

pretty = True # Default

if len(sys.argv) > 1:
filename = sys.argv[1]
else:
print('You need to supply an .pickle file - aborting')
sys.exit()

if len(sys.argv) > 2:
if sys.argv[2] == 'pretty' or 'p':
pretty = True
if sys.argv[2] == 'raw' or 'r':
pretty = False

with open(filename, 'rb') as f:
data = pickle.load(f)

if pretty:
pprint(data, compact=True)
else:
print(data)

0 comments on commit 6f87ff3

Please sign in to comment.