83 lines
2.6 KiB
Python
83 lines
2.6 KiB
Python
import os
|
|
import subprocess as xsub
|
|
import sys
|
|
import time
|
|
from typing import List
|
|
from PyQt5.QtWidgets import QApplication
|
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
|
|
from parse.StoryMap import XAST_ParseTool, storyline_list2map
|
|
from parse.StorylineCmp import CmpTool
|
|
from manage.MileStone import base_store_path, current_store_path
|
|
from frame.CompareViews import CompareWindow
|
|
from frame.ContentView import StorylinesView, ArticleRefsView
|
|
|
|
|
|
def git_save(target_dir: str):
|
|
retls = xsub.run("git status", shell=True, capture_output=True)
|
|
outlist = str(retls.stdout).split(r'\n')
|
|
has_changed:bool = False
|
|
|
|
files_path:List[str] = []
|
|
for o in outlist:
|
|
modified_flag = r"\tmodified:"
|
|
new_flag = r"\tnew file:"
|
|
delete_flag = r"\tdeleted:"
|
|
if o.startswith(modified_flag):
|
|
has_changed = True
|
|
files_path.append(o[len(modified_flag):])
|
|
|
|
elif o.startswith(new_flag):
|
|
has_changed = True
|
|
files_path.append(o[len(new_flag):])
|
|
|
|
elif o.startswith(delete_flag):
|
|
has_changed = True
|
|
files_path.append(o[len(delete_flag):])
|
|
|
|
if has_changed:
|
|
xsub.run(f"git add {" ".join(files_path)}", shell=True)
|
|
xsub.run(f"git commit -m 'save-at:{time.time()}'")
|
|
|
|
|
|
def nsc_compile(target_dir: str):
|
|
retls = xsub.run("nsc --path ./ --dest E:/", shell=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app = QApplication(sys.argv)
|
|
cmd_line = ":".join(sys.argv[1:])
|
|
|
|
#wnss:-cmp
|
|
if cmd_line == "wnss:-cmp":
|
|
git_save(os.getcwd())
|
|
nsc_compile(os.getcwd())
|
|
ast_old = XAST_ParseTool(base_store_path)
|
|
ast_new = XAST_ParseTool(current_store_path)
|
|
map_old = storyline_list2map(ast_old.story_list)
|
|
ast_old.storylines_plait(map_old)
|
|
map_new = storyline_list2map(ast_new.story_list)
|
|
ast_new.storylines_plait(map_new)
|
|
|
|
cmp_tool = CmpTool()
|
|
all_changed = cmp_tool.graph_compare(map_new, map_old)
|
|
present_view = CompareWindow(map_new, all_changed, None)
|
|
present_view.show()
|
|
pass
|
|
|
|
elif cmd_line == "wnss:-prsn":
|
|
git_save(os.getcwd())
|
|
nsc_compile(os.getcwd())
|
|
stool = XAST_ParseTool(current_store_path)
|
|
graph_curr = stool.get_story_graph()
|
|
story_lines_view = StorylinesView(None)
|
|
story_lines_view.show()
|
|
story_lines_view.present_stories_graph(graph_curr)
|
|
|
|
frags_curr = stool.get_article_nodes()
|
|
frags_refs_view = ArticleRefsView(None)
|
|
frags_refs_view.show()
|
|
frags_refs_view.present_volumes_graph(frags_curr)
|
|
|
|
pass
|
|
|
|
app.exec() |