Change AET var to string, NameError to ValueError
Python was giving errors with TRUE as a bool, so I changed it to a string. Giving an undefined name returned a different error than I put in the except, so I edited it and ran some tests which were successful. I will work on implementing something to detect if the subreddit exists and if it includes anything (e.g. special characters) which cannot be in subreddit names.
This commit is contained in:
1 parent
b1e1d07c8b
commit
f12f0da76d
2 files changed
+4
-4
No files matched your search
+1
-1
@@ -2,5 +2,5 @@ REDDIT_CLIENT_ID=""
|
||||
REDDIT_CLIENT_SECRET=""
|
||||
REDDIT_USERNAME=""
|
||||
REDDIT_PASSWORD=""
|
||||
ASK_EACH_TIME=TRUE
|
||||
ASK_EACH_TIME="TRUE"
|
||||
SUBREDDIT=""
|
||||
+3
-3
@@ -22,16 +22,16 @@ def get_subreddit_threads():
|
||||
password=os.getenv("REDDIT_PASSWORD"),
|
||||
)
|
||||
|
||||
if os.getenv("ASK_EACH_TIME") == TRUE:
|
||||
if os.getenv("ASK_EACH_TIME") == "TRUE":
|
||||
try:
|
||||
subreddit = reddit.subreddit(input("What subreddit would you like to pull from? "))
|
||||
except NameError:
|
||||
except ValueError:
|
||||
subreddit = reddit.subreddit("askreddit")
|
||||
print_substep("Subreddit not defined. Using AskReddit.")
|
||||
else:
|
||||
try:
|
||||
subreddit = reddit.subreddit(os.getenv("SUBREDDIT"))
|
||||
except NameError:
|
||||
except ValueError:
|
||||
subreddit = reddit.subreddit("askreddit")
|
||||
print_substep("Subreddit not defined. Using AskReddit.")
|
||||
|
||||
|
||||
Reference in new issue
Block a user