Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed news source selection crashing with incorrect inputs #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,25 @@ def NewsSources():
def App():
newsSources=NewsSources()
while True:
for i in xrange(len(newsSources)):
print ("["+str(i)+"]" +"\t" +newsSources[i])
print ("Please enter the index of the news source or press 99 to quit")
try:
newsSourceNumber=raw_input("News Source Number >>>> ")
except ValueError:
print ("That is not a valid News Source Number")
newsSourceNumber=int(newsSourceNumber)
if newsSourceNumber==99:
sys.exit()
if (newsSourceNumber >=len(newsSources)):
print ("Please select the index no less than "+ str(len(newsSources)))
newsSourceNumber_str= "initialization for the inputcheck"
newsSourceNumber = "initialization for the inputcheck"
while(newsSourceNumber >=len(newsSources) or not newsSourceNumber_str.isdigit() ):
for i in xrange(len(newsSources)):
print ("["+str(i)+"]" +"\t" +newsSources[i])
print ("Please enter the index of the news source or press 99 to quit")
try:
newsSourceNumber_str=raw_input("News Source Number >>>> ")
newsSourceNumber=int(newsSourceNumber_str)
except ValueError:
print ("That is not a valid News Source Number")
except AttributeError:
print ("That is not a valid News Source Number")

if newsSourceNumber==99:
sys.exit()
if (newsSourceNumber >=len(newsSources)):
print ("Please select the index no less than "+ str(len(newsSources)))

obj=NewsPulling(newsSources[newsSourceNumber])
Articles=obj.BeautifyArticles();
while True:
Expand Down