Merge branch 'main' of https://github.com/plexx-dev/Nassi-Shneiderman-Diagramm-Generator into main
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
__pycache__/
|
||||
15
.vscode/launch.json
vendored
Normal file
15
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Python: Aktuelle Datei",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "gui.py",
|
||||
"console": "integratedTerminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -39,25 +39,39 @@ class NassiShneidermanDiagram:
|
||||
if line and not re.match(r"""^//|^#|^COMMENT|^--""", line):
|
||||
lines.append(line)
|
||||
except:
|
||||
logging.error(f"Failed to open input path {filepath}!")
|
||||
logging.error(f"Failed to open input file {filepath}!")
|
||||
|
||||
return lines
|
||||
|
||||
def load_from_file(self, filepath: str):
|
||||
filtered_lines = self.load_code_lines(filepath)
|
||||
print(filtered_lines)
|
||||
num_brace
|
||||
global_scope = []
|
||||
current_scope = global_scope
|
||||
for line in filtered_lines:
|
||||
if line.startswith("while("):
|
||||
logging.debug(line)
|
||||
if line.__contains__('}'):
|
||||
current_scope.append("scope exit")
|
||||
current_scope = global_scope[-1] # does not get correct parent scope
|
||||
#TODO: get correct parent scope
|
||||
if line.__contains__('{'):
|
||||
current_scope.append("scope enter")
|
||||
current_scope.append([])
|
||||
current_scope = current_scope[-1]
|
||||
|
||||
elif not line.__contains__('}'):
|
||||
current_scope.append("generic instruction")
|
||||
print(global_scope)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
"""for debugging"""
|
||||
|
||||
|
||||
|
||||
"""if __name__ == "__main__":
|
||||
#for debugging
|
||||
from Iinstruction import *
|
||||
|
||||
NSD = NassiShneidermanDiagram(True)
|
||||
|
||||
NSD.load_from_file("res/input/input.java")
|
||||
|
||||
NSD.convert_to_image("Nina", 500)
|
||||
NSD.convert_to_image("Nina", 500)"""
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
# Nassi-Shneiderman-Diagramm-Generator
|
||||
This python code generates a Nassi Shneiderman Diagramm from Java Source Code
|
||||
|
||||
|
||||
How it works:
|
||||
In the final Version, you will just have to execute the nassi.exe and choose your Code, it will display the Nassi-Shneiderman-Diagramm and give you the path of the created picture.
|
||||
17
gui.py
17
gui.py
@@ -1,7 +1,11 @@
|
||||
|
||||
from to_nassi import nassi
|
||||
|
||||
import PySimpleGUI as sg
|
||||
import os.path
|
||||
|
||||
#sg.theme_previewer()
|
||||
|
||||
java_file_list_column = [
|
||||
[
|
||||
sg.Text('Java Folder'),
|
||||
@@ -46,7 +50,7 @@ layout = [
|
||||
]
|
||||
]
|
||||
|
||||
window = sg.Window('Nassi Viewer', layout)
|
||||
window = sg.Window('Nassi Viewer', layout, resizable=True)
|
||||
|
||||
while True:
|
||||
event, values = window.read()
|
||||
@@ -78,7 +82,6 @@ while True:
|
||||
pass
|
||||
if event == '-JAVA FOLDER-':
|
||||
folder = values['-JAVA FOLDER-']
|
||||
print(folder)
|
||||
try:
|
||||
file_list = os.listdir(folder)
|
||||
except:
|
||||
@@ -90,7 +93,17 @@ while True:
|
||||
and f.lower().endswith(('.java', '.txt'))
|
||||
]
|
||||
window['-JAVA FILE LIST-'].update(fnames)
|
||||
elif event == '-JAVA FILE LIST-':
|
||||
try:
|
||||
filename = os.path.join(
|
||||
values["-JAVA FOLDER-"], values["-JAVA FILE LIST-"][0]
|
||||
)
|
||||
|
||||
window["-TOUT-"].update(filename)
|
||||
nassi(filename)
|
||||
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
window.close()
|
||||
|
||||
8
to_nassi.py
Normal file
8
to_nassi.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from NassiShneidermann import NassiShneidermanDiagram
|
||||
from Iinstruction import *
|
||||
|
||||
|
||||
def nassi(filepath):
|
||||
NSD = NassiShneidermanDiagram(True)
|
||||
NSD.load_from_file(filepath)
|
||||
NSD.convert_to_image("Nina", 500)
|
||||
Reference in New Issue
Block a user