From 75648343e26f39a4cc75cdae5b37984c735a373a Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Mon, 27 Jan 2020 18:39:54 -0800 Subject: [PATCH] Rename timesearch.py -> get_submissions.py. --- timesearch_modules/__init__.py | 39 +++++++++++-------- .../{timesearch.py => get_submissions.py} | 7 ++-- 2 files changed, 25 insertions(+), 21 deletions(-) rename timesearch_modules/{timesearch.py => get_submissions.py} (97%) diff --git a/timesearch_modules/__init__.py b/timesearch_modules/__init__.py index ee39eb2..43a66cf 100644 --- a/timesearch_modules/__init__.py +++ b/timesearch_modules/__init__.py @@ -14,7 +14,7 @@ The subreddit archiver The basics: 1. Collect a subreddit's submissions - > timesearch.py timesearch -r subredditname + > timesearch.py get_submissions -r subredditname 2. Collect the comments for those submissions > timesearch.py commentaugment -r subredditname @@ -24,7 +24,7 @@ The basics: Commands for collecting: -{timesearch} +{get_submissions} {commentaugment} {livestream} {getstyles} @@ -232,13 +232,13 @@ redmash: performs all of the different mashes. ''', - 'timesearch': ''' -timesearch: + 'get_submissions': ''' +get_submissions: Collect submissions from the subreddit across all of history, or Collect submissions by a user (as many as possible). - > timesearch.py timesearch -r subredditname - > timesearch.py timesearch -u username + > timesearch.py get_submissions -r subredditname + > timesearch.py get_submissions -u username -r "test" | --subreddit "test": The subreddit to scan. Mutually exclusive with username. @@ -265,6 +265,10 @@ timesearch: ''', } +OLD_COMMAND_ALIASES = { + 'timesearch': 'get_submissions', +} + def docstring_preview(text): ''' @@ -325,9 +329,9 @@ def redmash_gateway(args): from . import redmash redmash.redmash_argparse(args) -def timesearch_gateway(args): - from . import timesearch - timesearch.timesearch_argparse(args) +def get_submissions_gateway(args): + from . import get_submissions + get_submissions.get_submissions_argparse(args) parser = argparse.ArgumentParser() @@ -394,19 +398,20 @@ p_redmash.add_argument('-st', '--score_threshold', dest='score_threshold', defau p_redmash.add_argument('-u', '--user', dest='username', default=None) p_redmash.set_defaults(func=redmash_gateway) -p_timesearch = subparsers.add_parser('timesearch') -p_timesearch.add_argument('-l', '--lower', dest='lower', default='update') -p_timesearch.add_argument('-r', '--subreddit', dest='subreddit', default=None) -p_timesearch.add_argument('-u', '--user', dest='username', default=None) -p_timesearch.add_argument('-up', '--upper', dest='upper', default=None) -p_timesearch.add_argument('-v', '--verbose', dest='verbose', action='store_true') -p_timesearch.add_argument('--dont_supplement', dest='do_supplement', action='store_false') -p_timesearch.set_defaults(func=timesearch_gateway) +p_get_submissions = subparsers.add_parser('get_submissions', aliases=['timesearch']) +p_get_submissions.add_argument('-l', '--lower', dest='lower', default='update') +p_get_submissions.add_argument('-r', '--subreddit', dest='subreddit', default=None) +p_get_submissions.add_argument('-u', '--user', dest='username', default=None) +p_get_submissions.add_argument('-up', '--upper', dest='upper', default=None) +p_get_submissions.add_argument('-v', '--verbose', dest='verbose', action='store_true') +p_get_submissions.add_argument('--dont_supplement', dest='do_supplement', action='store_false') +p_get_submissions.set_defaults(func=get_submissions_gateway) def main(argv): helpstrings = {'', 'help', '-h', '--help'} command = listget(argv, 0, '').lower() + command = OLD_COMMAND_ALIASES.get(command, command) # The user did not enter a command, or entered something unrecognized. if command not in MODULE_DOCSTRINGS: diff --git a/timesearch_modules/timesearch.py b/timesearch_modules/get_submissions.py similarity index 97% rename from timesearch_modules/timesearch.py rename to timesearch_modules/get_submissions.py index 2a2b289..5f0db88 100644 --- a/timesearch_modules/timesearch.py +++ b/timesearch_modules/get_submissions.py @@ -6,7 +6,6 @@ from . import exceptions from . import pushshift; print('Thank you Jason Baumgartner, owner of Pushshift.io!') from . import tsdb - def _normalize_subreddit(subreddit): if subreddit is None: pass @@ -25,7 +24,7 @@ def _normalize_user(user): raise TypeError(type(user)) return user -def timesearch( +def get_submissions( subreddit=None, username=None, lower=None, @@ -86,7 +85,7 @@ def timesearch( print('Ended with %d items in %s' % (itemcount, database.filepath.basename)) -def timesearch_argparse(args): +def get_submissions_argparse(args): if args.verbose: common.log.setLevel(common.logging.DEBUG) @@ -95,7 +94,7 @@ def timesearch_argparse(args): else: lower = common.int_none(args.lower) - return timesearch( + return get_submissions( subreddit=args.subreddit, username=args.username, lower=lower,