Slight tidy up plus alter the edit_only functionality

pull/7/merge
David Trail 11 years ago
parent aa5e2ecc34
commit d8ee3aab26

@ -66,15 +66,20 @@ else:
for thing in things:
thing_time = datetime.fromtimestamp(thing.created_utc)
before_time = datetime.utcnow() - timedelta(hours=hours)
if thing.id in whitelist_ids:
# Delete things after after_time
after_time = datetime.utcnow() - timedelta(hours=hours)
if thing_time > after_time:
continue
if thing_time > before_time:
# For edit_only we're assuming that the hours aren't altered.
# This saves time when deleting (you don't edit already edited posts).
if edit_only:
end_time = after_time - timedelta(hours=hours)
if thing_time < end_time:
continue
if str(thing.subreddit).lower() in whitelist:
if str(thing.subreddit).lower() in whitelist or \
thing.id in whitelist_ids:
continue
if not trial_run:
@ -86,9 +91,16 @@ for thing in things:
elif isinstance(thing, Comment):
replacement_text = get_sentence()
if verbose:
print 'Editing and deleting /r/{3}/ #{0} with:\n\t"{1}" to\n\t"{2}"'.format(
thing.id, sub(r'[\t\r\n]', ' ', thing.body.encode('ascii', 'ignore')[:78]),
replacement_text[:78], thing.subreddit)
msg = '/r/{3}/ #{0} with:\n\t"{1}" to\n\t"{2}"'.format(
thing.id,
sub(r'[\t\r\n]', ' ', thing.body.encode('ascii', 'ignore')[:78]),
replacement_text[:78],
thing.subreddit
)
if edit_only:
print 'Editing ' + msg
else:
print 'Editing and deleting ' + msg
thing.edit(replacement_text)
if not edit_only:
thing.delete()

Loading…
Cancel
Save