Merged changed from pteek with fixes.

pull/30/head
x89 10 years ago
parent 98adee0fba
commit 2658074f47

3
.gitignore vendored

@ -1,3 +1,6 @@
2015*.txt
2016*.txt
2017*.txt
*.cfg
*.pyc
shreddit.conf

@ -28,9 +28,6 @@ clear_vote = False
# Overview: both submissions and comments. Comments / Submitted are as expected.
item = overview
# Save comments and posts before deleting them?
keep_a_copy = True
# Anything in this list won't be deleted, coma delimited
# spaces should work as .strip() is called after splitting
# on comma.
@ -58,4 +55,7 @@ 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

@ -89,7 +89,7 @@ if keep_a_copy:
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))
@ -153,9 +153,9 @@ for thing in things:
elif 'selftext_html' in d:
del d['selftext_html']
thing_json = json.dumps(d)
if isinstance(thing, Submission):
if verbose && keep_a_copy:
if verbose and keep_a_copy:
print('Saving a copy of submission: #{id} {url}'.format(
id=thing.id,
url=thing.url)
@ -180,11 +180,12 @@ for thing in things:
print('Editing {msg}'.format(msg=msg))
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()
copy_file.close()
if keep_a_copy:
copy_file.close()

Loading…
Cancel
Save