mirror of
https://github.com/KevinMidboe/bulk-downloader-for-reddit.git
synced 2025-10-29 17:40:15 +00:00
Improved checkConflicts()
This commit is contained in:
25
script.py
25
script.py
@@ -160,24 +160,19 @@ def checkConflicts():
|
|||||||
values = {x: 0 if x is None or x is False else 1 for x in modes}
|
values = {x: 0 if x is None or x is False else 1 for x in modes}
|
||||||
|
|
||||||
if not sum(values[x] for x in values) == 1:
|
if not sum(values[x] for x in values) == 1:
|
||||||
print("Program mode is invalid")
|
raise ProgramModeError("Invalid program mode")
|
||||||
quit()
|
|
||||||
|
|
||||||
if values["search"]+values["saved"] == 2:
|
if values["search"]+values["saved"] == 2:
|
||||||
print("You cannot search in your saved posts")
|
raise SearchModeError("You cannot search in your saved posts")
|
||||||
quit()
|
|
||||||
|
|
||||||
if values["search"]+values["submitted"] == 2:
|
if values["search"]+values["submitted"] == 2:
|
||||||
print("You cannot search in submitted posts")
|
raise SearchModeError("You cannot search in submitted posts")
|
||||||
quit()
|
|
||||||
|
|
||||||
if values["search"]+values["upvoted"] == 2:
|
if values["search"]+values["upvoted"] == 2:
|
||||||
print("You cannot search in upvoted posts")
|
raise SearchModeError("You cannot search in upvoted posts")
|
||||||
quit()
|
|
||||||
|
|
||||||
if values["upvoted"]+values["submitted"] == 1 and user == 0:
|
if values["upvoted"]+values["submitted"] == 1 and user == 0:
|
||||||
print("No redditor name given")
|
raise RedditorNameError("No redditor name given")
|
||||||
quit()
|
|
||||||
|
|
||||||
class PromptUser:
|
class PromptUser:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -280,7 +275,6 @@ class PromptUser:
|
|||||||
|
|
||||||
elif programMode == "saved":
|
elif programMode == "saved":
|
||||||
GLOBAL.arguments.saved = True
|
GLOBAL.arguments.saved = True
|
||||||
GLOBAL.arguments.user = input("\nredditor: ")
|
|
||||||
|
|
||||||
elif programMode == "log":
|
elif programMode == "log":
|
||||||
GLOBAL.arguments.log = input("\nlog file directory:")
|
GLOBAL.arguments.log = input("\nlog file directory:")
|
||||||
@@ -562,10 +556,13 @@ def main():
|
|||||||
|
|
||||||
print(" ".join(sys.argv))
|
print(" ".join(sys.argv))
|
||||||
|
|
||||||
if len(sys.argv) == 1:
|
try:
|
||||||
PromptUser()
|
|
||||||
else:
|
|
||||||
checkConflicts()
|
checkConflicts()
|
||||||
|
except ProgramModeError as err:
|
||||||
|
PromptUser()
|
||||||
|
except Exception as err:
|
||||||
|
print(err)
|
||||||
|
quit()
|
||||||
|
|
||||||
GLOBAL.config = getConfig("config.json")
|
GLOBAL.config = getConfig("config.json")
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,15 @@ class FileNameTooLong(Exception):
|
|||||||
class InvalidRedditLink(Exception):
|
class InvalidRedditLink(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class ProgramModeError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class SearchModeError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class RedditorNameError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
class NoMatchingSubmissionFound(Exception):
|
class NoMatchingSubmissionFound(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user