diff --git a/autostack/main.py b/autostack/main.py index fc985e1..ded64e7 100644 --- a/autostack/main.py +++ b/autostack/main.py @@ -16,6 +16,10 @@ print_accepted_post ) +from autostack.option_features.features import ( + custom_query +) + EXCEPTIONS = [ 'Exception', 'StopIteration', @@ -106,8 +110,8 @@ def main(): # If three "no"s occur in a row let the user enter a custom query. if(no_counter == 3): no_counter = 0 - print('Enter a custom query: ', end='') - + custom_query() + break continue if __name__ == "__main__": diff --git a/autostack/option_features/__init__.py b/autostack/option_features/__init__.py new file mode 100644 index 0000000..f3a1eb9 --- /dev/null +++ b/autostack/option_features/__init__.py @@ -0,0 +1,8 @@ +''' +Authors: Elijah Sawyers, Benjamin Sanders +Emails: elijahsawyers@gmail.com, ben.sanders97@gmail.com +Date: 07/29/2019 +Overview: Contains various extra features and options. +''' + +from .features import custom_query \ No newline at end of file diff --git a/autostack/option_features/features.py b/autostack/option_features/features.py new file mode 100644 index 0000000..53ce278 --- /dev/null +++ b/autostack/option_features/features.py @@ -0,0 +1,37 @@ +''' +Authors: Elijah Sawyers, Benjamin Sanders +Emails: elijahsawyers@gmail.com, ben.sanders97@gmail.com +Date: 07/29/2019 +Overview: Contains extra features for autostack. +''' + +from __future__ import print_function +from autostack.web_scraper.stack_overflow_scraper import ( + accepted_posts, + print_accepted_post +) + +def custom_query(): + ''' + Allows the user to submit a custom query to search on Stack Overflow. + ''' + + print('Enter a custom query: ', end='') + new_query = input() + + for post in accepted_posts(new_query): + # Display Stack Overflow posts for the error. + print_accepted_post(post) + + # If the user's question has been answered, + # don't keep looping over posts. + while True: + print('Did this answer your question? (Y/n): ', end='') + question_answered = input() + if question_answered == 'Y' or question_answered == 'n': + break + if question_answered == 'Y': + print(u'\U0001F95E Listening for Python errors...') + break + elif question_answered == 'n': + continue \ No newline at end of file