From 67ccc3944265742b5416a65aea3778ca9ae315e3 Mon Sep 17 00:00:00 2001 From: Scott Date: Tue, 13 Dec 2016 15:41:22 -0600 Subject: [PATCH] Fixes JSON output regression in PRAW4 --- setup.py | 2 +- shreddit/shredder.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 632fb27..212480b 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup from codecs import open from os import path -VERSION = "6.0.2" +VERSION = "6.0.3" DESCRIPTION = " Remove your comment history on Reddit as deleting an account does not do so." here = path.abspath(path.dirname(__file__)) diff --git a/shreddit/shredder.py b/shreddit/shredder.py index e54d432..9b456c8 100644 --- a/shreddit/shredder.py +++ b/shreddit/shredder.py @@ -97,8 +97,12 @@ class Shredder(object): return False def _save_item(self, item): - with open(os.path.join(self._save_directory, item.id), "w") as fh: - json.dump(item.json_dict, fh) + with open(os.path.join(self._save_directory, "{}.json".format(item.id)), "w") as fh: + # This is a temporary replacement for the old .json_dict property: + output = {k: item.__dict__[k] for k in item.__dict__ if not k.startswith("_")} + output["subreddit"] = output["subreddit"].title + output["author"] = output["author"].name + json.dump(output, fh) def _remove_submission(self, sub): self._logger.info("Deleting submission: #{id} {url}".format(id=sub.id, url=sub.url.encode("utf-8")))