Skip to content

Commit d39210b

Browse files
author
George K. Thiruvathukal
committed
remove use of pickle for counter info - use JSON instead
1 parent 5cc0f53 commit d39210b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

zettelgeist/zettel.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import os
1717
import os.path
18-
import pickle
18+
import json
1919
import shutil
2020

2121
from time import strftime
@@ -721,18 +721,18 @@ def process_zettel_command_line_options(z, vargs, id):
721721
def get_count(counter_path, counter_name):
722722
# Create counter db if not present.
723723
if not os.path.exists(counter_path):
724-
with open(counter_path, 'ab') as dbfile:
725-
pickle.dump({}, dbfile)
724+
with open(counter_path, 'w') as dbfile:
725+
json.dump({}, dbfile)
726726

727727
# Read count from counter. If non-existent, start at 0.
728-
with open(counter_path, 'rb') as dbfile:
729-
db = pickle.load(dbfile)
728+
with open(counter_path, 'r') as dbfile:
729+
db = json.load(dbfile)
730730
count = db.get(counter_name, -1) + 1
731731

732732
# save count for next invocation
733-
with open(counter_path, 'wb') as dbfile:
733+
with open(counter_path, 'w') as dbfile:
734734
db[counter_name] = count
735-
pickle.dump(db, dbfile)
735+
json.dump(db, dbfile)
736736
return count
737737

738738
def dict_as_yaml(data):

0 commit comments

Comments
 (0)