Skip to content

Commit

Permalink
Added custom query function and option/features class
Browse files Browse the repository at this point in the history
  • Loading branch information
BenOSanders committed Jul 30, 2019
1 parent 0a9790c commit 97cfbf8
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
8 changes: 6 additions & 2 deletions autostack/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
print_accepted_post
)

from autostack.option_features.features import (
custom_query
)

EXCEPTIONS = [
'Exception',
'StopIteration',
Expand Down Expand Up @@ -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__":
Expand Down
8 changes: 8 additions & 0 deletions autostack/option_features/__init__.py
Original file line number Diff line number Diff line change
@@ -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
37 changes: 37 additions & 0 deletions autostack/option_features/features.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 97cfbf8

Please sign in to comment.