From aafe828d3797d12036d586a9e1b9ac9c7315bebc Mon Sep 17 00:00:00 2001 From: sctop <2094880085@qq.com> Date: Sun, 24 Mar 2024 16:58:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E5=88=86bug=E8=A7=84=E9=81=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data | 2 +- .../actual_data/_story/story_part_auto.py | 57 +++++++++++++------ data_model/actual_data/story.py | 2 +- main_quick_test.py | 22 +++++++ 4 files changed, 65 insertions(+), 18 deletions(-) create mode 100644 main_quick_test.py diff --git a/data b/data index cc5a598..d224c7b 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit cc5a5987b5b026bac6ae76375f6ff35b999a4666 +Subproject commit d224c7b569ba284abc6252f25dd404b3e8fbd2a8 diff --git a/data_model/actual_data/_story/story_part_auto.py b/data_model/actual_data/_story/story_part_auto.py index 11b9e62..fc635eb 100644 --- a/data_model/actual_data/_story/story_part_auto.py +++ b/data_model/actual_data/_story/story_part_auto.py @@ -1,3 +1,4 @@ +import logging from collections import OrderedDict from data_model.actual_data.track import TrackInfo @@ -19,9 +20,12 @@ def __init__(self, data, story): def load(self): # bg for i in self.data["background"]: - temp = BackgroundInfo.get_instance(i) - temp.register(self.story) - self.background[i] = temp + try: + temp = BackgroundInfo.get_instance(i) + temp.register(self.story) + self.background[i] = temp + except KeyError: + logging.warning("No track info about: " + repr(i)) # track for i in self.data["track"]: temp = TrackInfo.get_instance(i) @@ -29,9 +33,12 @@ def load(self): self.track[i] = temp # character for i in self.data["character"]: - temp = CharacterInfo.get_instance(i) - temp.register(self.story) - self.character[i] = temp + try: + temp = CharacterInfo.get_instance(i) + temp.register(self.story) + self.character[i] = temp + except KeyError: + logging.warning("No character info about: " + repr(i)) def to_json(self): return { @@ -74,13 +81,15 @@ def load(self): for (track_id, bgs) in self.data["track_to_bg"].items(): if track_id == "OST_0": continue - track = self.data_all.track[track_id] for bg_id in bgs: if bg_id in ["BG_Red.jpg", "BG_Black.jpg", "BG_White.jpg"]: continue - bg = self.data_all.background[bg_id] + try: + bg = self.data_all.background[bg_id] + except KeyError: + continue track.register(bg) bg.register(track) @@ -94,21 +103,31 @@ def load(self): track = self.data_all.track[track_id] for char_id in chars: - char = self.data_all.character[char_id] + try: + char = self.data_all.character[char_id] + except KeyError: + continue - track.register(char) - char.register(track) + track.register(char) + char.register(track) - self._char_to_track[char_id] = track_id + self._char_to_track[char_id] = track_id # char to bg for (char_id, bgs) in self.data["char_to_bg"].items(): - char = self.data_all.character[char_id] + try: + char = self.data_all.character[char_id] + except KeyError: + continue + for bg_id in bgs: if bg_id in ["BG_Red.jpg", "BG_Black.jpg", "BG_White.jpg"]: continue - bg = self.data_all.background[bg_id] + try: + bg = self.data_all.background[bg_id] + except KeyError: + continue char.register(bg) bg.register(char) @@ -117,10 +136,16 @@ def load(self): # char to char for (char_id, data) in self.data["char_to_char"].items(): - char1 = self.data_all.character[char_id] + try: + char1 = self.data_all.character[char_id] + except KeyError: + continue for char2_id in data: - char2 = self.data_all.character[char2_id] + try: + char2 = self.data_all.character[char2_id] + except KeyError: + continue char1.register(char2) char2.register(char1) diff --git a/data_model/actual_data/story.py b/data_model/actual_data/story.py index 78d4033..8a8af48 100644 --- a/data_model/actual_data/story.py +++ b/data_model/actual_data/story.py @@ -406,7 +406,7 @@ def to_json_basic(data): class StoryInfoAuto(StoryInfo, StoryInfoAutoMixin): def __init__(self, **kwargs): - super().__init__(data=kwargs["data"], namespace=kwargs["namespace"], parent_data=kwargs["parent_data"]) + FileLoader.__init__(self, data=kwargs["data"], namespace=kwargs["namespace"], parent_data=kwargs["parent_data"]) data = kwargs["data"] self.is_battle = data["is_battle"] diff --git a/main_quick_test.py b/main_quick_test.py new file mode 100644 index 0000000..f6cf3bb --- /dev/null +++ b/main_quick_test.py @@ -0,0 +1,22 @@ +import time + +from data_model.loader.loader_detect import get_loader_by_filepath +from data_model.actual_data.virtual_loader import * +from data_model.tool.tool import PostExecutionManager + +start_time = time.time() +TAGS = get_loader_by_filepath([], r"data/tag", None) +TRACKS = get_loader_by_filepath([], r"data/track", None) +BACKGROUNDS = get_loader_by_filepath([], r"data/background", None) +CHARACTERS = get_loader_by_filepath([], r"data/character", None) +STORIES = get_loader_by_filepath(["main"], r"data/main/story", None) +BATTLES = get_loader_by_filepath(["main"], r"data/main/battle", None) +UIS = get_loader_by_filepath([], r"data/ui", None) +VIDEOS = get_loader_by_filepath([], r"data/video", None) +EVENTS = get_loader_by_filepath([], r"data/event", None) +ALBUMS = get_loader_by_filepath([], r"data/album", None) +FolderLoaderAccesser(TAGS, TRACKS, BACKGROUNDS, CHARACTERS, STORIES, BATTLES, UIS, VIDEOS, EVENTS, ALBUMS) +PostExecutionManager.execute_pool("related_to") +PostExecutionManager.execute_pool("reference_data") +PostExecutionManager.execute_pool("background_character_direct") +print(f"Linking Stuff Together: {time.time() - start_time:0.2f}") \ No newline at end of file