diff --git a/__pycache__/Iinstruction.cpython-39.pyc b/__pycache__/Iinstruction.cpython-39.pyc deleted file mode 100644 index 8d97961..0000000 Binary files a/__pycache__/Iinstruction.cpython-39.pyc and /dev/null differ diff --git a/__pycache__/code_to_image.cpython-39.pyc b/__pycache__/code_to_image.cpython-39.pyc deleted file mode 100644 index f3c1216..0000000 Binary files a/__pycache__/code_to_image.cpython-39.pyc and /dev/null differ diff --git a/gui/gui.py b/gui/gui.py index 9f5fb6c..2056490 100644 --- a/gui/gui.py +++ b/gui/gui.py @@ -99,9 +99,12 @@ class Gui: 'You didn\'t set a name for the image, it will be named randomly.') output_name = secrets.token_hex(16) - path = nassi(input_path=file_path, output_path=output_path, outputname=output_name, gui=self, + path, file_is_empty = nassi(input_path=file_path, output_path=output_path, outputname=output_name, gui=self, font_filepath=font_filepath, behaviour=exists_choice, types=types, remove_tags=modifier, comments=comments) - if path: + + if file_is_empty: + sg.popup_annoying('Our interpreter did not find anything. --> blame Kons or yourself!', title='Empty') + elif path: fnames = output(path) sg.popup_annoying('Successfully created!', title='Created', auto_close_duration=2, auto_close=True, text_color='green') @@ -163,10 +166,14 @@ class Gui: # handle event select output folder if event == '-OUTPUT FOLDER-': - logging.debug(('event = ' + str(event) + - ' value = ' + str(values['-OUTPUT FOLDER-']))) - fnames = output(values['-OUTPUT FOLDER-']) - window['-OUTPUT FILE LIST-'].update(fnames) + try: + logging.debug(('event = ' + str(event) + + ' value = ' + str(values['-OUTPUT FOLDER-']))) + fnames = output(values['-OUTPUT FOLDER-']) + window['-OUTPUT FILE LIST-'].update(fnames) + except Exception as e: + logging.error(str(e)) + sg.popup_error(str(e)) elif event == '-OUTPUT FILE LIST-': logging.debug(('event = ' + str(event) + ' value = ' + str(values['-OUTPUT FILE LIST-']))) diff --git a/gui/utils.py b/gui/utils.py index 395b514..4db3e28 100644 --- a/gui/utils.py +++ b/gui/utils.py @@ -23,13 +23,14 @@ def nassi(input_path: str, output_path: str, outputname: str, types, remove_tags custom_tags = {"comments" : comments, "ignore" : remove_tags, "types" : types} - NSD.load_from_file(input_path, custom_tags) - cancel = NSD.convert_to_image(output_directory, on_conflict=behaviour) + is_empty = NSD.load_from_file(input_path, custom_tags) + cancel = NSD.convert_to_image(output_directory, on_conflict=behaviour) + if not cancel: return None - return output_directory + return output_directory, is_empty diff --git a/interpreter/NassiShneidermann.py b/interpreter/NassiShneidermann.py index 09a5835..8f551ea 100644 --- a/interpreter/NassiShneidermann.py +++ b/interpreter/NassiShneidermann.py @@ -84,4 +84,9 @@ class NassiShneidermanDiagram: def load_from_file(self, filepath:str, itp_custom_tags: Optional[Dict[str, List[str]]]): itp = JavaInterpreter(filepath) itp.reset_tags(itp_custom_tags) - self.function_scopes = itp.load_instruction_scopes() \ No newline at end of file + self.function_scopes = itp.load_instruction_scopes() + + if not self.function_scopes: + return True + else: + return False \ No newline at end of file