+ warning overwrite
This commit is contained in:
0
errors/__init__.py
Normal file
0
errors/__init__.py
Normal file
8
errors/custom.py
Normal file
8
errors/custom.py
Normal file
@@ -0,0 +1,8 @@
|
||||
class InterpreterError(Exception):
|
||||
pass
|
||||
|
||||
class JavaSyntaxError(Exception):
|
||||
pass
|
||||
|
||||
class ScopeNotFoundException(Exception):
|
||||
pass
|
||||
25
gui/gui.py
25
gui/gui.py
@@ -1,4 +1,4 @@
|
||||
from gui.utils import nassi, output
|
||||
from gui.utils import nassi, output, file_there
|
||||
from interpreter.interpret_source import JavaSyntaxError, ScopeNotFoundException
|
||||
|
||||
import PySimpleGUI as sg
|
||||
@@ -147,17 +147,24 @@ class Gui:
|
||||
file_path = os.path.join(
|
||||
values["-JAVA FOLDER-"],
|
||||
)
|
||||
output_path = values['-OUTPUT FOLDER-']
|
||||
nassi(filepath=file_path, output_path=output_path, outputname=output_name, gui=self,
|
||||
font_filepath=font_filepath)
|
||||
|
||||
fnames = output(values)
|
||||
sg.popup_annoying('Successful created!', title='Created',
|
||||
auto_close_duration=2, auto_close=True, text_color='green')
|
||||
window['-OUTPUT FILE LIST-'].update(fnames)
|
||||
|
||||
|
||||
|
||||
output_path = values['-OUTPUT FOLDER-']
|
||||
|
||||
if file_there((output_path + '/' + output_name)) is False:
|
||||
proceed = sg.popup_yes_no('File already exist! Continue?', title='File alreday exist!')
|
||||
print(proceed)
|
||||
if proceed == 'Yes':
|
||||
nassi(filepath=file_path, output_path=output_path, outputname=output_name, gui=self,
|
||||
font_filepath=font_filepath)
|
||||
|
||||
fnames = output(values)
|
||||
sg.popup_annoying('Successful created!', title='Created',
|
||||
auto_close_duration=2, auto_close=True, text_color='green')
|
||||
window['-OUTPUT FILE LIST-'].update(fnames)
|
||||
else:
|
||||
pass
|
||||
except JavaSyntaxError as JsE:
|
||||
logging.error(
|
||||
('||SyntaxError in Java File|| Failed to create Image with values = ' + str(values)))
|
||||
|
||||
20
gui/utils.py
20
gui/utils.py
@@ -4,17 +4,19 @@ import os
|
||||
from interpreter.NassiShneidermann import NassiShneidermanDiagram
|
||||
from draw.Iinstruction import *
|
||||
|
||||
def nassi(filepath:str, output_path: str, outputname, gui, font_filepath=None):
|
||||
|
||||
def nassi(filepath: str, output_path: str, outputname, gui, font_filepath=None):
|
||||
NSD = NassiShneidermanDiagram(gui.debug_mode)
|
||||
#if font_filepath is None:
|
||||
# if font_filepath is None:
|
||||
# pass
|
||||
#else:
|
||||
#if font_filepath is not None or font_filepath != "":
|
||||
# else:
|
||||
# if font_filepath is not None or font_filepath != "":
|
||||
if font_filepath != None:
|
||||
NSD.set_font(str(font_filepath))
|
||||
NSD.load_from_file(filepath)
|
||||
NSD.convert_to_image(output_path, outputname, 500)
|
||||
|
||||
|
||||
def output(values):
|
||||
output_path = values['-OUTPUT FOLDER-']
|
||||
try:
|
||||
@@ -28,3 +30,13 @@ def output(values):
|
||||
and f.lower().endswith(('.png', '.gif'))
|
||||
]
|
||||
return fnames
|
||||
|
||||
|
||||
def file_there(file):
|
||||
try:
|
||||
open((file + '.png'))
|
||||
return False
|
||||
except FileNotFoundError:
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
@@ -3,17 +3,9 @@ from os import remove
|
||||
import re
|
||||
from typing import Callable, List, Tuple
|
||||
|
||||
from errors.custom import InterpreterError, JavaSyntaxError, ScopeNotFoundException
|
||||
from draw.Iinstruction import *
|
||||
|
||||
class InterpreterError(Exception):
|
||||
pass
|
||||
|
||||
class JavaSyntaxError(Exception):
|
||||
pass
|
||||
|
||||
class ScopeNotFoundException(Exception):
|
||||
pass
|
||||
|
||||
COMMENT_REGEX = r"""^//|^#|^COMMENT|^--"""
|
||||
REMOVE_KEYWORDS = [' ', "public", "private", "void", ';']
|
||||
|
||||
|
||||
Reference in New Issue
Block a user