2024-07-29 03:52:28 +00:00
|
|
|
import sys, os
|
|
|
|
import subprocess as xsub
|
|
|
|
import time
|
2024-07-29 03:58:41 +00:00
|
|
|
from typing import List
|
2024-07-29 04:56:42 +00:00
|
|
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
|
2024-07-29 04:50:59 +00:00
|
|
|
from parse.StoryMap import XAST_ParseTool, StoryMap, FragmentSlice, storyline_list2map
|
|
|
|
from parse.StorylineCmp import CmpTool, ModifyReason
|
|
|
|
from manage.MileStone import base_store_path, current_store_path
|
2024-07-29 03:52:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
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
|
2024-07-29 03:58:41 +00:00
|
|
|
|
|
|
|
files_path:List[str] = []
|
2024-07-29 03:52:28 +00:00
|
|
|
for o in outlist:
|
2024-07-29 03:58:41 +00:00
|
|
|
modified_flag = r"\tmodified:"
|
2024-07-29 04:01:14 +00:00
|
|
|
new_flag = r"\tnew file:"
|
2024-07-29 04:41:56 +00:00
|
|
|
delete_flag = r"\tdeleted:"
|
2024-07-29 03:58:41 +00:00
|
|
|
if o.startswith(modified_flag):
|
2024-07-29 03:52:28 +00:00
|
|
|
has_changed = True
|
2024-07-29 03:58:41 +00:00
|
|
|
files_path.append(o[len(modified_flag):])
|
|
|
|
|
2024-07-29 04:01:14 +00:00
|
|
|
elif o.startswith(new_flag):
|
2024-07-29 03:52:28 +00:00
|
|
|
has_changed = True
|
2024-07-29 04:01:14 +00:00
|
|
|
files_path.append(o[len(new_flag):])
|
2024-07-29 03:52:28 +00:00
|
|
|
|
2024-07-29 04:41:56 +00:00
|
|
|
elif o.startswith(delete_flag):
|
|
|
|
has_changed = True
|
|
|
|
files_path.append(o[len(delete_flag):])
|
|
|
|
|
2024-07-29 03:52:28 +00:00
|
|
|
if has_changed:
|
2024-07-29 04:01:14 +00:00
|
|
|
xsub.run(f"git add {" ".join(files_path)}", shell=True)
|
2024-07-29 03:52:28 +00:00
|
|
|
xsub.run(f"git commit -m 'save-at:{time.time()}'")
|
|
|
|
|
|
|
|
|
2024-07-29 04:41:56 +00:00
|
|
|
def nsc_compile(target_dir: str):
|
|
|
|
retls = xsub.run("nsc --path ./ --dest E:/", shell=True)
|
|
|
|
|
|
|
|
|
2024-07-29 03:52:28 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
print(sys.argv)
|
|
|
|
cmd_line = ":".join(sys.argv[1:])
|
2024-07-29 04:41:56 +00:00
|
|
|
|
2024-07-29 03:52:28 +00:00
|
|
|
#wnss:-cmp
|
|
|
|
if cmd_line == "wnss:-cmp":
|
2024-07-29 04:41:56 +00:00
|
|
|
git_save(os.getcwd())
|
2024-07-29 04:50:59 +00:00
|
|
|
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)
|
|
|
|
map_new = storyline_list2map(ast_new.story_list)
|
|
|
|
|
|
|
|
cmp_tool = CmpTool()
|
|
|
|
all_changed = cmp_tool.graph_compare(map_new, map_old)
|
|
|
|
print(all_changed)
|