Merge branch 'klloe-save_path'

pull/100/head
David John 8 years ago
commit dad90aa6be

@ -98,7 +98,11 @@ class Shredder(object):
return False return False
def _save_item(self, item): def _save_item(self, item):
with open(os.path.join(self._save_directory, "{}.json".format(item.id)), "w") as fh: name = item.subreddit_name_prefixed[2:]
path = "{}/{}/{}.json".format(item.author, name, item.id)
if not os.path.exists(os.path.join(self._save_directory, os.path.dirname(path))):
os.makedirs(os.path.join(self._save_directory, os.path.dirname(path)))
with open(os.path.join(self._save_directory, path), "w") as fh:
# This is a temporary replacement for the old .json_dict property: # 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 = {k: item.__dict__[k] for k in item.__dict__ if not k.startswith("_")}
output["subreddit"] = output["subreddit"].title output["subreddit"] = output["subreddit"].title

Loading…
Cancel
Save