From 6e4abff74ac38bec676a3cf30428dfa1b6ac2b18 Mon Sep 17 00:00:00 2001 From: x89 Date: Sun, 12 Apr 2015 23:54:26 +0100 Subject: [PATCH] Removed buggy and superflous code. --- shreddit.cfg.example | 3 --- shreddit.py | 31 +------------------------------ 2 files changed, 1 insertion(+), 33 deletions(-) diff --git a/shreddit.cfg.example b/shreddit.cfg.example index f34a167..e839e0f 100644 --- a/shreddit.cfg.example +++ b/shreddit.cfg.example @@ -55,7 +55,4 @@ whitelist_gilded = True # except on whitelisted subreddits but after 3 months delete everything. nuke_hours = 0 -# Save a copy to disk of comments and posts before deleting them. -keep_a_copy = False - # vim: syntax=config diff --git a/shreddit.py b/shreddit.py index e24c8a3..335e7b9 100755 --- a/shreddit.py +++ b/shreddit.py @@ -53,16 +53,13 @@ clear_vote = config.getboolean('main', 'clear_vote') trial_run = config.getboolean('main', 'trial_run') edit_only = config.getboolean('main', 'edit_only') item = config.get('main', 'item') -keep_a_copy = config.getboolean('main', 'keep_a_copy') whitelist_distinguished = config.getboolean('main', 'whitelist_distinguished') whitelist_gilded = config.getboolean('main', 'whitelist_gilded') nuke_hours = config.getint('main', 'nuke_hours') _user = config.get('main', 'username') _pass = config.get('main', 'password') -r = praw.Reddit(user_agent="shreddit/3.2") -if keep_a_copy: - r.config.store_json_result = True +r = praw.Reddit(user_agent="shreddit/3.3") def login(user=None, password=None): try: @@ -83,12 +80,6 @@ if not r.is_logged_in(): if verbose: print("Logged in as {user}".format(user=r.user)) -if keep_a_copy: - fname = str(datetime.utcnow()).replace(':','')+'.txt' - if verbose: - print("Saving {user}'s stuff in {name}".format(user=r.user, name=fname)) - copy_file = open(fname, 'w') - if verbose: print("Deleting messages before {time}.".format( time=datetime.now() - timedelta(hours=hours)) @@ -145,22 +136,7 @@ for thing in things: if clear_vote: thing.clear_vote() - #html is not playing well with json - d = thing.json_dict - if 'body_html' in d: - del d['body_html'] - elif 'selftext_html' in d: - del d['selftext_html'] - thing_json = json.dumps(d) - if isinstance(thing, Submission): - if verbose and keep_a_copy: - print('Saving a copy of submission: #{id} {url}'.format( - id=thing.id, - url=thing.url) - ) - if keep_a_copy: - copy_file.write(thing_json + '\n') if verbose: print('Deleting submission: #{id} {url}'.format( id=thing.id, @@ -180,11 +156,6 @@ for thing in things: else: print('Editing and deleting {msg}'.format(msg=msg)) - if keep_a_copy: - copy_file.write(thing_json + '\n') thing.edit(replacement_text) if not edit_only: thing.delete() - -if keep_a_copy: - copy_file.close()