I have 2 scripts, `script_A` and `script_B` where `script_B` is my main
code.
In `B`, I have the following commands...
class dialogManager(QtGui.QDialog):
def __init__(self, type="", parent=None):
...
things_to_exclude = script_A.get_list_of_exclusions(type)
things_to_check = script_A.get_list_of_checked_items(type)
...
Generally, the function contents for both `get_list_of_exclusions` and
`get_list_of_checked_items` are the same with the exception of its name..
def get_list_of_exclusions(type):
file_path = os.path.join(
config_path, file_template.format(type=type)
)
if not os.path.exists(file_path):
raise Exception('Config does not exist for the exclusions!'
'\n{0}'.format(file_path)
)
with open(file_path) as mapping_file:
mapping_data = json.load(file_path)
return file_path
Though it may be a bit overkill but I was thinking of writing a check like
what happens if `type` is not defined or if the developers did not entered
in a valid `type`...
class dialogManager(QtGui.QDialog):
def __init__(self, type="", parent=None):
...
if type == "":
raise IOError("Nothing is defined for the type. Please contact
dev!")
sys.exit()
things_to_exclude = script_A.get_list_of_exclusions(type)
things_to_check = script_A.get_list_of_checked_items(type)
if not things_to_exclude or things_to_check:
# How do I handle that the Exceptions that were already raised,
supposed if the files does not exists etc.
...
But I am stumped at the portion of getting the already raised Exceptions...
I checked online and derived answers of using try...except.. is that the
only way to do so?
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/b30c4134-210f-44aa-a5c2-31e44204bcb4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.