From d9231fa1313a9d016cc360008f998cd0f7c97854 Mon Sep 17 00:00:00 2001 From: codeboss <2422523675@qq.com> Date: Sun, 14 Jul 2024 20:25:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/workspace.xml | 44 ++++++++--- entry.py | 8 +- parse/__pycache__/__init__.cpython-312.pyc | Bin 0 -> 144 bytes parse/__pycache__/ast_load.cpython-312.pyc | Bin 0 -> 3391 bytes parse/ast_load.py | 87 ++++++++++++++++++++- 5 files changed, 121 insertions(+), 18 deletions(-) create mode 100644 parse/__pycache__/__init__.cpython-312.pyc create mode 100644 parse/__pycache__/ast_load.cpython-312.pyc diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f003f87..de3eb34 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,15 +5,9 @@ - - - - - - - - - + + + + + + + + + + + + + diff --git a/entry.py b/entry.py index baa955a..a8fd386 100644 --- a/entry.py +++ b/entry.py @@ -1,8 +1,8 @@ from PyQt5.QtWidgets import QWidget, QApplication from sys import argv +from parse.ast_load import global_ast_path, AstParse -app = QApplication(argv) -win = QWidget() -win.show() -app.exec() \ No newline at end of file +tool = AstParse(global_ast_path) +print(tool.generate_time()) +tool.peak_storylines() \ No newline at end of file diff --git a/parse/__pycache__/__init__.cpython-312.pyc b/parse/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fd33a098c62f6ef74408cf3e80d2d0e6806f3e44 GIT binary patch literal 144 zcmX@j%ge<81aUJar-A6lAOanHW&w&!XQ*V*Wb|9fP{ah}eFmxdrSD=D6Ht_&m6}{q z91~Dkl98Vm6I_yCR2h<=pHm!DkXTfl8WSI%nU`4-AFo$X`HRCQH$SB`C)KWq6{w#P Rh>JmtkIamWj77{q769adB7y(_ literal 0 HcmV?d00001 diff --git a/parse/__pycache__/ast_load.cpython-312.pyc b/parse/__pycache__/ast_load.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ff056517af0620da596cb47b72e0aea9bbf6d2b5 GIT binary patch literal 3391 zcmcH*O>YxNboR?$J8=?79O8W8B&5Mb#83!=v=pjBktjq+K`IJ~Rwla%PW_S2ELCjT zhyw>pye`edX)4fsF3p?qM_PWzOA*0R43ioLAo8U+GqZcnPtGzkO*4sj z${1gXF>~JLZo~Rhq;>$-Ys4Tkf=*^cT`;5tQ5WyZGqNsmTn1dpC=rhp_>9IDlSay% zPQ>R8%g5r2shD|-8uJb}XqAd34NbHB znwCuKw-SiAYT8$~Vu|{W#7s)t-~vVMo)CVSzfK`i2?uC$)(hY+sfv;kD2~(!OjWJ}P7(R<+XZY}y z8+sW+(IpYd4yFKlPGb-(@pOt=?F;qT)ffgZqb+cDr(3wWvYp$axlw{9Wc>iPqhw%z zL4L0GR`w6!++R^!xv4B~{k;Z_Fd2A4OacNCLzZA}9!q$lY2<{b^;8jvqn$`m63Y`? zUN%y?6Jvuw+o_DzY47u7a*U82+@ahq`yph40Q6K_H`Lye+Pk3+mDHi)*mL!LS4o9i z@c&eC0ED1n0FHjcfH&wDtjpi%)ol3B8aAFl&O3GNFRA?->PSf)DW2b<<5WbYU2v2J z5p*Nihk&Ql5Mn%y4j|Tp0F%?sFU%;40E3ae2LSU+w(|?7YAYnx`mq}3S5-y)^p0G^ ziw(KvghlNH?EHgVlMIjHMJGbWDUfk$#uM>c>L<*+g7wi-u|O`z%$p7Vli>mn(cAo$ z#-uYH8K9Qyg42BRVoqFA;CRz`T3_cS6DtfKOIT=|Mow~q8&cZkV|N6R-iUbU7~HVr zG{m_jQzNERl*5v)UA|;%5l=BQBHKllpXItO#1nNbu>dgCEDXbT4*D;<$1#SR;pj(p z3;;xaPZ$brV6$`IL$!FI+&NZIE1i97r&muuI8#tJdj=l+9{Gv~%RPtin41$GYCt1Q z&AY7)n4!4bs8<2`H+c_6uJh4FbY)&JT?1{`glQ;sQ`tZi9D4oeT=c9NPZ|`fAymM_ zFj>k9`k4oAJ&!D3%rvQnCmXUUuxO+V8Z!;PmF;#7)IdK3OxY*^uu@mg+U3>D8(m|i zuCev@a@WZp_msLmEciCt_ufDC&FyFE08fbqd!P>79!EgC|7MT8kQ2_4xv#+{7=FmD zY3QPBJBiy)+P0l8=cFv0cTVKxckoc$6G~2j_n-shJvn*F4e0Gha~|icK<)))@(zyf zsk}Gmt#ed!>R)S+_aVo7D>797h<7UMM_)%7{_S;Ws1$ntX@S^|C@ErsI_3E#0=>}_88EkAFq_+QB^87HgF zc|?nwMv_?yUt0l}j7%8*6=5#g!~Pj+Up8W2YMeV~nC)?cuW2U=x7l|9ApC-%wYk-~ zjo`sj@ZfrXIe4Pre;M4rMOu6lh4Yor;N!kWeZ?=zp~LI3Qs_wG;%4uG;qHN=M&DN3_%t{Xu@-F;VI0swzOQs$_8F@%2a7 z*Zax?6NRZtXl#oJfr str: - self.ast_inst.xpath + def generate_time(self) -> str: + attr_time = self.ast_inst.xpath("/ast[1]/@time")[0] + return str(attr_time) + + def peak_storylines(self) -> List[StorySlice]: + story_list = self.ast_inst.xpath("/ast/story") # 获取所有故事节点 + + story_items = [] + for story in story_list: + story_name = story.xpath("@name")[0] + story_slice = StorySlice("story:"+story_name) + story_items.append(story_slice) + + story_text_lines = story.xpath("text-section/@text") # 获取所有描述 + for line in story_text_lines: + story_slice.append_text_section(line) + pass + + fragment_items = story.xpath("fragment") # 获取所有情节定义 + for fragm in fragment_items: + fragment_name = fragm.xpath("@name") + fragm_slice = FragmentSlice("fragment:"+story_name+"#"+fragment_name) + fragm_text_lines = fragm.xpath("text-section/@text") + for line in fragm_text_lines: + fragm_slice.append_text_section(line) + pass + pass + pass + + fragm_refers = self.ast_inst.xpath("//refer") + for refer in fragm_refers: + story_name = refer.xpath("@story") + fragm_name = refer.xpath("@fragment") + story_refers = items_filter(story_items, lambda x:x.signature == f"story:{story_name}") + if(len(story_refers) > 0): + story_refer = story_refers[0] + + + return story_items