+ 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
|
||||||
15
gui/gui.py
15
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
|
from interpreter.interpret_source import JavaSyntaxError, ScopeNotFoundException
|
||||||
|
|
||||||
import PySimpleGUI as sg
|
import PySimpleGUI as sg
|
||||||
@@ -147,7 +147,15 @@ class Gui:
|
|||||||
file_path = os.path.join(
|
file_path = os.path.join(
|
||||||
values["-JAVA FOLDER-"],
|
values["-JAVA FOLDER-"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
output_path = values['-OUTPUT FOLDER-']
|
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,
|
nassi(filepath=file_path, output_path=output_path, outputname=output_name, gui=self,
|
||||||
font_filepath=font_filepath)
|
font_filepath=font_filepath)
|
||||||
|
|
||||||
@@ -155,9 +163,8 @@ class Gui:
|
|||||||
sg.popup_annoying('Successful created!', title='Created',
|
sg.popup_annoying('Successful created!', title='Created',
|
||||||
auto_close_duration=2, auto_close=True, text_color='green')
|
auto_close_duration=2, auto_close=True, text_color='green')
|
||||||
window['-OUTPUT FILE LIST-'].update(fnames)
|
window['-OUTPUT FILE LIST-'].update(fnames)
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
except JavaSyntaxError as JsE:
|
except JavaSyntaxError as JsE:
|
||||||
logging.error(
|
logging.error(
|
||||||
('||SyntaxError in Java File|| Failed to create Image with values = ' + str(values)))
|
('||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 interpreter.NassiShneidermann import NassiShneidermanDiagram
|
||||||
from draw.Iinstruction import *
|
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)
|
NSD = NassiShneidermanDiagram(gui.debug_mode)
|
||||||
#if font_filepath is None:
|
# if font_filepath is None:
|
||||||
# pass
|
# pass
|
||||||
#else:
|
# else:
|
||||||
#if font_filepath is not None or font_filepath != "":
|
# if font_filepath is not None or font_filepath != "":
|
||||||
if font_filepath != None:
|
if font_filepath != None:
|
||||||
NSD.set_font(str(font_filepath))
|
NSD.set_font(str(font_filepath))
|
||||||
NSD.load_from_file(filepath)
|
NSD.load_from_file(filepath)
|
||||||
NSD.convert_to_image(output_path, outputname, 500)
|
NSD.convert_to_image(output_path, outputname, 500)
|
||||||
|
|
||||||
|
|
||||||
def output(values):
|
def output(values):
|
||||||
output_path = values['-OUTPUT FOLDER-']
|
output_path = values['-OUTPUT FOLDER-']
|
||||||
try:
|
try:
|
||||||
@@ -28,3 +30,13 @@ def output(values):
|
|||||||
and f.lower().endswith(('.png', '.gif'))
|
and f.lower().endswith(('.png', '.gif'))
|
||||||
]
|
]
|
||||||
return fnames
|
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
|
import re
|
||||||
from typing import Callable, List, Tuple
|
from typing import Callable, List, Tuple
|
||||||
|
|
||||||
|
from errors.custom import InterpreterError, JavaSyntaxError, ScopeNotFoundException
|
||||||
from draw.Iinstruction import *
|
from draw.Iinstruction import *
|
||||||
|
|
||||||
class InterpreterError(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
class JavaSyntaxError(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
class ScopeNotFoundException(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
COMMENT_REGEX = r"""^//|^#|^COMMENT|^--"""
|
COMMENT_REGEX = r"""^//|^#|^COMMENT|^--"""
|
||||||
REMOVE_KEYWORDS = [' ', "public", "private", "void", ';']
|
REMOVE_KEYWORDS = [' ', "public", "private", "void", ';']
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user