From a6424babc4737ae94a00f8e7fc25635afbba5400 Mon Sep 17 00:00:00 2001 From: sctop <2094880085@qq.com> Date: Wed, 3 Apr 2024 23:40:27 +0800 Subject: [PATCH 01/12] =?UTF-8?q?StoryInfoAuto=20=E4=BA=BA=E7=89=A9-?= =?UTF-8?q?=E4=BA=BA=E7=89=A9=E4=B9=8B=E9=97=B4=E5=A4=9A=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E4=BA=86=E4=B8=80=E6=AC=A1=E5=AF=BC=E8=87=B4counter=E4=B8=8D?= =?UTF-8?q?=E5=87=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data_model/actual_data/_story/story_part_auto.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/data_model/actual_data/_story/story_part_auto.py b/data_model/actual_data/_story/story_part_auto.py index af63a34..58ec4ac 100644 --- a/data_model/actual_data/_story/story_part_auto.py +++ b/data_model/actual_data/_story/story_part_auto.py @@ -140,6 +140,7 @@ def load(self): self._char_to_bg[char_id] = bg.uuid # char to char + _char_to_char = [] for (char_id, data) in self.data["char_to_char"].items(): try: char1 = self.data_all.character[char_id] @@ -152,6 +153,14 @@ def load(self): except KeyError: continue + # 唯一识别ID,防止二次注册 + _ctc_id1 = f"{char_id}_{char2_id}" + _ctc_id2 = f"{char2_id}_{char_id}" + if _ctc_id1 in _char_to_char or _ctc_id2 in _char_to_char: + continue + _char_to_char.append(_ctc_id1) + _char_to_char.append(_ctc_id2) + char1.register(char2) char2.register(char1) From a13c1110c90772bec397fd0d7aa79619c16c58a5 Mon Sep 17 00:00:00 2001 From: sctop <2094880085@qq.com> Date: Wed, 3 Apr 2024 23:45:54 +0800 Subject: [PATCH 02/12] StudentInfo added gacha intro text i18n --- data_model/actual_data/character.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/data_model/actual_data/character.py b/data_model/actual_data/character.py index 0a50a9d..77efc53 100644 --- a/data_model/actual_data/character.py +++ b/data_model/actual_data/character.py @@ -317,6 +317,8 @@ def __init__(self, **kwargs): self._bond_track = None self._bond_rank = -1 + self.profile_intro = i18n_translator.query(f"[CHARACTER_{self._id}_GET_DIALOG_TEXT]") + self.used_by = CharacterUsedBy() if "related_to" not in kwargs["data"].keys(): self.related_to = CharacterRelatedTo(self, CharacterRelatedTo.BLANK_DATA) @@ -372,7 +374,8 @@ def to_json(self): }, "profile": { "profile": self.profile.to_json(), - "gacha": self.profile_gacha.to_json() + "gacha": self.profile_gacha.to_json(), + "intro": self.profile_intro.to_json() }, "school": { "short": self.school.to_json(), From 42dd4a00c47d930c0b4773aa0c3708ab0b7c4b6d Mon Sep 17 00:00:00 2001 From: sctop <2094880085@qq.com> Date: Sat, 13 Apr 2024 17:13:33 +0800 Subject: [PATCH 03/12] ComposerInfo added --- data | 2 +- data_model/actual_data/composer.py | 109 +++++++++++++++++++++++++++++ data_model/actual_data/track.py | 11 ++- data_model/constant/file_type.py | 2 + data_model/loader/folder_loader.py | 10 +++ data_model/loader/loader_detect.py | 9 ++- main.py | 7 ++ 7 files changed, 146 insertions(+), 4 deletions(-) create mode 100644 data_model/actual_data/composer.py diff --git a/data b/data index d4fa66d..6616821 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit d4fa66de36a2b97a94cfd8ab2ac361758e02c7dd +Subproject commit 661682144e89d030425b9fe3cff71f2c045d0556 diff --git a/data_model/actual_data/composer.py b/data_model/actual_data/composer.py new file mode 100644 index 0000000..b1bccce --- /dev/null +++ b/data_model/actual_data/composer.py @@ -0,0 +1,109 @@ +from ..loader import FileLoader +from .used_by import BaseUsedBy, UsedByRegisterMixin, OrderedDictWithCounter, UsedByToJsonMixin +from ..constant.file_type import FILETYPES_TRACK +from ..tool.interpage import InterpageMixin +from ..types.url import UrlModel +from ..tool.tool import ObjectAccessProxier + + +class ComposerUsedBy(BaseUsedBy, UsedByToJsonMixin): + SUPPORTED_FILETYPE = [*FILETYPES_TRACK] + _components = ["data_track"] + + def __init__(self): + self.data_track = OrderedDictWithCounter() + + def register(self, file_loader: FileLoader, count_increase=True): + filetype = file_loader.filetype + instance_id = file_loader.instance_id + + if filetype in self.SUPPORTED_FILETYPE: + if filetype in FILETYPES_TRACK: + self.data_track[instance_id] = file_loader + if not count_increase: + self.data_track.counter_adjust(instance_id, -1) + else: + raise ValueError + + +class NameMasker(ObjectAccessProxier): + def __init__(self, obj: str): + """兼容Interpage相关策略""" + super().__init__(obj) + + def to_json(self): + return { + "en": self._object, + "zh_cn": self._object, + "jp": self._object + } + + def to_json_basic(self): + return self.to_json() + + +class ComposerInfo(FileLoader, UsedByRegisterMixin, InterpageMixin): + _instance = {} + + def __init__(self, **kwargs): + super().__init__(data=kwargs["data"], namespace=kwargs["namespace"], parent_data=kwargs["parent_data"]) + self.data = data = kwargs["data"] + + self.no = data["no"] + self.name = NameMasker(data["name"]["nickname"]) + self.realname = data["name"]["realname"] + self.nickname = data["name"]["nickname"] + self.intro = data["intro"] + + self.contact = UrlModel() + self.contact.load(data["contact"]) + + self.used_by = ComposerUsedBy() + + @staticmethod + def _get_instance_id(data: dict): + return str(data["no"]) + + def to_json(self): + d = { + "uuid": self.uuid, + "filetype": self.filetype, + + "name": self.name.to_json(), + "namespace": self.namespace, + "realname": self.realname, + "nickname": self.nickname, + "intro": self.intro, + "contact": self.contact.to_json(), + + "used_by": self.used_by.to_json(), + "interpage": self.get_interpage_data() + } + return d + + def to_json_basic(self): + d = { + "uuid": self.uuid, + "filetype": self.filetype, + + "name": self.name.to_json(), + "namespace": self.namespace, + "realname": self.realname, + "nickname": self.nickname, + "intro": self.intro, + "contact": self.contact.to_json(), + + "interpage": self.get_interpage_data() + } + return d + + def _get_instance_offset(self, offset: int): + keys = list(self._instance.keys()) + curr_index = keys.index(self.instance_id) + + try: + if curr_index == 0 and offset < 0: + return None + return self._instance[keys[curr_index + offset]] + except (IndexError, KeyError): + return None diff --git a/data_model/actual_data/track.py b/data_model/actual_data/track.py index 8ce3f3b..c98cae2 100644 --- a/data_model/actual_data/track.py +++ b/data_model/actual_data/track.py @@ -1,22 +1,29 @@ from itertools import chain from collections import OrderedDict + from data_model.types.url import * from data_model.types.metatype.base_type import * from data_model.types.metatype.base_model import * from data_model.types.metatype.complex import * from data_model.types.lang_string import * + from data_model.loader import i18n_translator, FileLoader from data_model.loader.manager_constant import constant_manager + from data_model.actual_data.used_by import BaseUsedBy, UsedByRegisterMixin, OrderedDictWithCounter, UsedByToJsonMixin from data_model.actual_data.related_to import BaseRelatedTo, RelatedToJsonMixin, RelatedToRegisterMixin from data_model.actual_data._track.track_version import * +from data_model.actual_data.tag import TagListManager +from data_model.actual_data.composer import ComposerInfo + from data_model.constant.file_type import FILETYPES_STORY, FILETYPES_BATTLE, FILETYPES_BACKGROUND, \ FILE_VIDEO_INFO, FILETYPES_TRACK, FILE_STORY_EVENT, FILE_BATTLE_EVENT, FILE_UI_EVENT, FILE_UI_CHILD, \ FILETYPES_CHARACTER, FILE_STUDENT_INFO, \ FILE_STORY_BOND, FLAG_STORY_BATTLE -from data_model.actual_data.tag import TagListManager + from data_model.tool.tool import seconds_to_minutes from data_model.tool.interpage import InterpageMixin + from ..tool.tool import counter_dict_sorter, PostExecutionManager __all__ = ["TrackInfo", "TrackListManager"] @@ -395,7 +402,7 @@ def __init__(self, **kwargs): self.desc = i18n_translator[data["desc"]] # Other stuff - self.composer = Composer().load(data["composer"]) + self.composer = ComposerInfo.get_instance(str(data["composer"]["composer_id"])) self.composer.register(self) self.tags = TrackTags('tags', self) self.version = TrackVersionListManager('version') diff --git a/data_model/constant/file_type.py b/data_model/constant/file_type.py index 873af26..9770f30 100644 --- a/data_model/constant/file_type.py +++ b/data_model/constant/file_type.py @@ -6,6 +6,7 @@ FILE_TRACK_ANIMATION = 3 FILE_TRACK_OTHER = 4 FILE_ALBUM = 5 +FILE_COMPOSER = 6 FILE_STORY_MAIN = 11 FILE_STORY_SIDE = 12 @@ -46,6 +47,7 @@ FILE_DIR_TRACK_ALL = -11 # /data/track FILE_DIR_TRACK_CATEGORY = -12 # /data/track/xxx FILE_DIR_ALBUM_ALL = -13 # /data/album +FILE_DIR_COMPOSER_ALL = -14 # /data/composer FILE_DIR_MAIN_ALL = -21 # /data/main/all.json FILE_DIR_MAIN_STORY_ALL = -22 # /data/main/story/all.json diff --git a/data_model/loader/folder_loader.py b/data_model/loader/folder_loader.py index a8603f5..ecf1e2c 100644 --- a/data_model/loader/folder_loader.py +++ b/data_model/loader/folder_loader.py @@ -253,3 +253,13 @@ def auto_include(self): temp = super().auto_include() temp.sort(key=self.sort_by_int) return temp + + +class ComposerLoader(GenericFolder): + def __init__(self, namespace: list, basepath, json_data=None, parent_data=None): + super().__init__(namespace, basepath, json_data, parent_data) + + def auto_include(self): + temp = super().auto_include() + temp.sort(key=self.sort_by_int) + return temp diff --git a/data_model/loader/loader_detect.py b/data_model/loader/loader_detect.py index 16d8118..e740e96 100644 --- a/data_model/loader/loader_detect.py +++ b/data_model/loader/loader_detect.py @@ -2,6 +2,7 @@ import json import os.path from ..constant.file_type import FILETYPES_TRACK, FILETYPES_TRACK_DIR, FILE_ALBUM, FILE_DIR_ALBUM_ALL, \ + FILE_COMPOSER, FILE_DIR_COMPOSER_ALL, \ FILE_TAG_INFO, FILE_DIR_TAG_ALL, \ FILE_DIR_CHARACTER_ALL, FILE_DIR_CHARACTER_CATEGORY, FILE_DIR_STUDENT_SINGLE, FILE_DIR_STUDENT_BOND, \ FILE_STORY_BOND, FILETYPES_STORY, FILETYPES_STORY_DIR, FILE_CHARACTER_INFO, \ @@ -15,8 +16,9 @@ FILE_REFERENCE_DATA from ..actual_data.track import TrackInfo from ..actual_data.track_album import AlbumInfo +from ..actual_data.composer import ComposerInfo from .folder_loader import TrackFolder, TagFolder, CharacterLoader, BackgroundLoader, StoryLoader, UiLoader, \ - BattleLoader, VideoLoader, EventLoader, AlbumLoader + BattleLoader, VideoLoader, EventLoader, AlbumLoader, ComposerLoader from ..actual_data.tag import TagInfo from ..actual_data.story import storyinfo_dispatcher from ..actual_data.background import BackgroundInfo @@ -206,6 +208,11 @@ def detect(entry): elif entry.filetype == FILE_DIR_ALBUM_ALL: yield AlbumLoader(namespace=entry.namespace, json_data=entry.data, basepath=entry.filepath, parent_data=entry.parent_data) + elif entry.filetype == FILE_COMPOSER: + yield ComposerInfo(data=entry.data, namespace=entry.namespace, parent_data=entry.parent_data) + elif entry.filetype == FILE_DIR_COMPOSER_ALL: + yield ComposerLoader(namespace=entry.namespace, json_data=entry.data, + basepath=entry.filepath, parent_data=entry.parent_data) else: yield from TrackLoaderDetect.next_detect.detect(entry) diff --git a/main.py b/main.py index 30bd89b..ae4745e 100644 --- a/main.py +++ b/main.py @@ -10,6 +10,7 @@ start_time = time.time() TAGS = get_loader_by_filepath([], r"data/tag", None) +COMPOSERS = get_loader_by_filepath([], r"data/composer", 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) @@ -81,6 +82,12 @@ def write_loader3(target_loader): for i in TAGS.including: write_loader(i) +# export composers +print("Exporting composer") +write_loader2(COMPOSERS) +for i in COMPOSERS.including: + write_loader(i) + # export tracks print("Exporting track") write_loader2(TRACKS) From fecd4b7fc194abda387c183c4d6021d213abbbb7 Mon Sep 17 00:00:00 2001 From: sctop <2094880085@qq.com> Date: Sat, 13 Apr 2024 17:14:44 +0800 Subject: [PATCH 04/12] updated testing script (not exporting to actual file) --- .github/workflows/dev.yaml | 4 +- .github/workflows/pull_request.yaml | 4 +- main_quick_test.py | 126 +++++++++++++++++++++++++++- 3 files changed, 129 insertions(+), 5 deletions(-) diff --git a/.github/workflows/dev.yaml b/.github/workflows/dev.yaml index 7d6eb8f..afa8889 100644 --- a/.github/workflows/dev.yaml +++ b/.github/workflows/dev.yaml @@ -23,5 +23,5 @@ jobs: git submodule update --remote # Run main script to test if it can work - - name: Run main.py - run: python main.py \ No newline at end of file + - name: Run testing script + run: python main_quick_test.py \ No newline at end of file diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index e3ebc56..6d0edd8 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -22,5 +22,5 @@ jobs: git submodule update --remote # Run main script to test if it can work - - name: Run main.py - run: python main.py \ No newline at end of file + - name: Run testing script + run: python main_quick_test.py \ No newline at end of file diff --git a/main_quick_test.py b/main_quick_test.py index f6cf3bb..ef44105 100644 --- a/main_quick_test.py +++ b/main_quick_test.py @@ -1,4 +1,7 @@ import time +import os +import json +from functools import partial from data_model.loader.loader_detect import get_loader_by_filepath from data_model.actual_data.virtual_loader import * @@ -6,6 +9,7 @@ start_time = time.time() TAGS = get_loader_by_filepath([], r"data/tag", None) +COMPOSERS = get_loader_by_filepath([], r"data/composer", 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) @@ -19,4 +23,124 @@ 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 +print(f"Linking Stuff Together: {time.time() - start_time:0.2f}") + +dump_json = partial(json.dumps, ensure_ascii=False) + + +def write_loader(target_loader): + """XxxInfo专用""" + loader = target_loader.loader + dump_json(loader.to_json()) + + +def write_loader2(target_loader): + """XxxLoader专用""" + loader = target_loader + dump_json(loader.to_json()) + + +def write_loader3(target_loader): + """VirtualData专用""" + loader = target_loader + dump_json(loader.to_json()) + + +start_time = time.time() + +# export tags +print("Exporting tag") +write_loader2(TAGS) +for i in TAGS.including: + write_loader(i) + +# export composers +print("Exporting composer") +write_loader2(COMPOSERS) +for i in COMPOSERS.including: + write_loader(i) + +# export tracks +print("Exporting track") +write_loader2(TRACKS) +for track_type in TRACKS.including: + write_loader2(track_type.loader) + for track in track_type.loader.including: + write_loader(track) + +# export backgrounds +print("Exporting background") +write_loader2(BACKGROUNDS) +for background in BACKGROUNDS.including: + write_loader(background) + +# export characters +print("Exporting character") +write_loader2(CHARACTERS) +for char_type in CHARACTERS.including: + write_loader2(char_type.loader) + for char in char_type.loader.including: + loader = char.loader + dump_json(loader.to_json()) + + if char.loader.filetype == -53: + for bond_dir in char.loader.including: + for bond in bond_dir.loader.including: + write_loader(bond) + +# export stories +print("Exporing story") +write_loader2(STORIES) +for story_type in STORIES.including: + write_loader2(story_type.loader) + for volume in story_type.loader.including: + write_loader2(volume.loader) + for chapter in volume.loader.including: + write_loader2(chapter.loader) + for segment in chapter.loader.including: + write_loader(segment) + +# export battle +print("Exporting battle") +write_loader2(BATTLES) +for battle_type in BATTLES.including: + write_loader2(battle_type.loader) + # for main + if battle_type.loader.namespace[-1] == "main": + for chapter in battle_type.loader.including: + write_loader2(chapter.loader) + for segment in chapter.loader.including: + write_loader(segment) + else: + for segment in battle_type.loader.including: + write_loader(segment) + +# export ui +print("Exporting UI") +write_loader2(UIS) +for ui in UIS.including: + write_loader(ui) + +# export videos +print("Exporting video") +write_loader2(VIDEOS) +for video in VIDEOS.including: + write_loader(video) + +# export events +print("Exporting event") +write_loader2(EVENTS) +for event_id in EVENTS.including: + write_loader2(event_id.loader) + for folder in event_id.loader.including: + write_loader2(folder.loader) + for file in folder.loader.including: + write_loader(file) + +# export albums +print("Exporting album") +write_loader2(ALBUMS) +for album in ALBUMS.including: + write_loader(album) + +print(f"Exporting test complate: {time.time() - start_time:0.2f}") From 3964ece920c830ba9ea27876c0bf769b88d8425c Mon Sep 17 00:00:00 2001 From: sctop <2094880085@qq.com> Date: Sat, 13 Apr 2024 21:52:34 +0800 Subject: [PATCH 05/12] fix: ComposerInfo data export --- data | 2 +- data_model/actual_data/composer.py | 18 ++++++----- data_model/actual_data/track.py | 50 ------------------------------ 3 files changed, 12 insertions(+), 58 deletions(-) diff --git a/data b/data index 6616821..e74ea84 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit 661682144e89d030425b9fe3cff71f2c045d0556 +Subproject commit e74ea844b0735362ee07f252c323a50e0e0fbe22 diff --git a/data_model/actual_data/composer.py b/data_model/actual_data/composer.py index b1bccce..67d8e7f 100644 --- a/data_model/actual_data/composer.py +++ b/data_model/actual_data/composer.py @@ -1,5 +1,7 @@ +from collections import OrderedDict + from ..loader import FileLoader -from .used_by import BaseUsedBy, UsedByRegisterMixin, OrderedDictWithCounter, UsedByToJsonMixin +from .used_by import BaseUsedBy, UsedByRegisterMixin, UsedByToJsonMixin from ..constant.file_type import FILETYPES_TRACK from ..tool.interpage import InterpageMixin from ..types.url import UrlModel @@ -8,10 +10,9 @@ class ComposerUsedBy(BaseUsedBy, UsedByToJsonMixin): SUPPORTED_FILETYPE = [*FILETYPES_TRACK] - _components = ["data_track"] def __init__(self): - self.data_track = OrderedDictWithCounter() + self.data_track = OrderedDict() def register(self, file_loader: FileLoader, count_increase=True): filetype = file_loader.filetype @@ -20,11 +21,12 @@ def register(self, file_loader: FileLoader, count_increase=True): if filetype in self.SUPPORTED_FILETYPE: if filetype in FILETYPES_TRACK: self.data_track[instance_id] = file_loader - if not count_increase: - self.data_track.counter_adjust(instance_id, -1) else: raise ValueError + def to_json(self, no_used_by: bool = True): + return {"data_track": [i.to_json_basic() for i in self.data_track.values()]} + class NameMasker(ObjectAccessProxier): def __init__(self, obj: str): @@ -68,9 +70,10 @@ def to_json(self): d = { "uuid": self.uuid, "filetype": self.filetype, + "namespace": self.namespace, "name": self.name.to_json(), - "namespace": self.namespace, + "no": self.no, "realname": self.realname, "nickname": self.nickname, "intro": self.intro, @@ -85,9 +88,10 @@ def to_json_basic(self): d = { "uuid": self.uuid, "filetype": self.filetype, + "namespace": self.namespace, "name": self.name.to_json(), - "namespace": self.namespace, + "no": self.no, "realname": self.realname, "nickname": self.nickname, "intro": self.intro, diff --git a/data_model/actual_data/track.py b/data_model/actual_data/track.py index c98cae2..5705a08 100644 --- a/data_model/actual_data/track.py +++ b/data_model/actual_data/track.py @@ -322,56 +322,6 @@ def to_json_basic(self): return self.to_json() -class Composer(BaseDataModel, UsedByRegisterMixin): - """ - Defines a `composer` dict. - - Note: This class implements irregular Singleton behaviour, in which when - you're loading the data, it might return an existing instance if - there's a match in either the `nickname` or `composer_id`. - """ - realname = String("realname") - nickname = String("nickname") - _components = ["composer_id", "realname", "nickname", "contact"] - _instance = {} - - def __init__(self, key_name="composer"): - super().__init__(key_name) - self.contact = Contact() - self.used_by = ComposerUsedBy() - - def load(self, value: dict): - self.composer_id = str(value.get("composer_id", "")) - if self.composer_id in self._instance.keys(): - return self._instance[self.composer_id] - - # If none is found, then it's the first time to create - # Check if the composer is auto-indexed - if value.get("composer_id", "") != "": - value = constant_manager.query("composer", value["composer_id"]) - super().load(value) - - self.realname = value["realname"] - self.nickname = value["nickname"] - self.contact.load(value["contact"]) - - self._instance[self.composer_id] = self - - return self - - def to_json(self): - return {"composer_id": self.composer_id, - "realname": self.realname, - "nickname": self.nickname, - "contact": self.contact.to_json_basic(), - "used_by": self.used_by.to_json_basic()} - - def to_json_basic(self): - return {"composer_id": self.composer_id, - "nickname": self.nickname, - "contact": self.contact.to_json_basic()} - - # ------------------------------------------------------- class TrackInfo(FileLoader, UsedByRegisterMixin, InterpageMixin, RelatedToRegisterMixin): From 6b96bd71218a411fadbe81377692140647874b96 Mon Sep 17 00:00:00 2001 From: sctop <2094880085@qq.com> Date: Sat, 13 Apr 2024 22:12:17 +0800 Subject: [PATCH 06/12] BREAKING-CHANGE: TagInfoUsedBy now exports in lists --- data | 2 +- data_model/actual_data/tag.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/data b/data index e74ea84..af5ae35 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit e74ea844b0735362ee07f252c323a50e0e0fbe22 +Subproject commit af5ae355097ff6174c98890357a870fb918ea224 diff --git a/data_model/actual_data/tag.py b/data_model/actual_data/tag.py index 90d0d69..2887013 100644 --- a/data_model/actual_data/tag.py +++ b/data_model/actual_data/tag.py @@ -30,6 +30,12 @@ def register(self, file_loader: FileLoader, count_increase=True): else: raise ValueError + def to_json(self, no_used_by: bool = True): + return { + "data_track": [i.to_json_basic() for i in self.data_track.values()], + "data_background": [i.to_json_basic() for i in self.data_background.values()] + } + class TagInfo(FileLoader, UsedByRegisterMixin, InterpageMixin): _color_to_css = {"green": "success", "blue": "primary", From cfbbb4cfd7956e82e881ff34fa78db557ac96f4c Mon Sep 17 00:00:00 2001 From: sctop <2094880085@qq.com> Date: Sun, 14 Apr 2024 00:54:52 +0800 Subject: [PATCH 07/12] BREAKING-CHANGE: support v2 generation --- .github/workflows/dev.yaml | 2 +- .github/workflows/push.yaml | 25 ++++++++++--------------- data | 2 +- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/.github/workflows/dev.yaml b/.github/workflows/dev.yaml index afa8889..8965a27 100644 --- a/.github/workflows/dev.yaml +++ b/.github/workflows/dev.yaml @@ -3,7 +3,7 @@ name: Dev Branch on: push: branches: - - 'dev' + - 'dev_v2' jobs: build: diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 6219319..1f997ea 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -3,10 +3,10 @@ name: Push on: push: branches: - - 'main' + - 'main_v2' workflow_dispatch: repository_dispatch: - types: [ost-data-update-event] + types: [ost-data-push-direct] jobs: build: @@ -24,16 +24,11 @@ jobs: - name: Update submodules run: | git submodule update --remote - - name: Run main.py - run: python main.py - - name: Push changes - run: | - git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" - git config --global user.name "github-actions[bot]" - cd data_export - git add . - git commit -m "Update: ${{ github.event.head_commit.message }}" - git config -l | grep 'http\..*\.extraheader' | cut -d= -f1 | xargs -L1 git config --unset-all - git push https://github-actions[bot]:$REPO_KEY@github.com/BA-OST-Index/ost_data_export.git HEAD:main - env: - REPO_KEY: ${{secrets.ACTION_SCRIPT}} \ No newline at end of file + - name: Run main_quick_test.py + run: python main_quick_test.py + - name: Generator Dispatch + uses: peter-evans/repository-dispatch@v1 + with: + token: ${{ secrets.ACTION_SCRIPT }} + event-type: ost-data-parser-push-direct + repository: BA-OST-Index/ost_data_site_generator \ No newline at end of file diff --git a/data b/data index af5ae35..b95b9e6 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit af5ae355097ff6174c98890357a870fb918ea224 +Subproject commit b95b9e614c126187dd637b887fc2a704d1b570e7 From 41fe5a020de59a773ab0fb0861ba9375937acbb9 Mon Sep 17 00:00:00 2001 From: sctop <2094880085@qq.com> Date: Sun, 14 Apr 2024 00:59:26 +0800 Subject: [PATCH 08/12] BREAKING-CHANGE: ost_data_export is not submodule --- .github/workflows/dev.yaml | 4 +++- .github/workflows/pull_request.yaml | 4 +++- .github/workflows/push.yaml | 4 +++- .gitmodules | 4 ---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/dev.yaml b/.github/workflows/dev.yaml index 8965a27..56fa327 100644 --- a/.github/workflows/dev.yaml +++ b/.github/workflows/dev.yaml @@ -24,4 +24,6 @@ jobs: # Run main script to test if it can work - name: Run testing script - run: python main_quick_test.py \ No newline at end of file + run: | + mkdir -p data_export + python main_quick_test.py \ No newline at end of file diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 6d0edd8..0674849 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -23,4 +23,6 @@ jobs: # Run main script to test if it can work - name: Run testing script - run: python main_quick_test.py \ No newline at end of file + run: | + mkdir -p data_export + python main_quick_test.py \ No newline at end of file diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 1f997ea..8a40575 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -25,7 +25,9 @@ jobs: run: | git submodule update --remote - name: Run main_quick_test.py - run: python main_quick_test.py + run: | + mkdir -p data_export + python main_quick_test.py - name: Generator Dispatch uses: peter-evans/repository-dispatch@v1 with: diff --git a/.gitmodules b/.gitmodules index 30a836c..edba14a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,8 +1,4 @@ [submodule "data"] path = data url = https://github.com/BA-OST-Index/ost_data.git - branch = main -[submodule "data_export"] - path = data_export - url = https://github.com/BA-OST-Index/ost_data_export.git branch = main \ No newline at end of file From aeb2d0dac71278aa5cb0b25f8b98a05f75e65000 Mon Sep 17 00:00:00 2001 From: sctop <2094880085@qq.com> Date: Sun, 14 Apr 2024 01:03:26 +0800 Subject: [PATCH 09/12] BREAKING-CHANGE: get submodules manually --- .github/workflows/dev.yaml | 4 +--- .github/workflows/pull_request.yaml | 4 +--- .github/workflows/push.yaml | 7 +------ 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/dev.yaml b/.github/workflows/dev.yaml index 56fa327..28a0c10 100644 --- a/.github/workflows/dev.yaml +++ b/.github/workflows/dev.yaml @@ -18,12 +18,10 @@ jobs: uses: actions/setup-python@v2 with: python-version: '3.x' - - name: Update submodules - run: | - git submodule update --remote # Run main script to test if it can work - name: Run testing script run: | + git clone https://github.com/BA-OST-Index/ost_data.git data mkdir -p data_export python main_quick_test.py \ No newline at end of file diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 0674849..78fa185 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -17,12 +17,10 @@ jobs: uses: actions/setup-python@v2 with: python-version: '3.x' - - name: Update submodules - run: | - git submodule update --remote # Run main script to test if it can work - name: Run testing script run: | + git clone https://github.com/BA-OST-Index/ost_data.git data mkdir -p data_export python main_quick_test.py \ No newline at end of file diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 8a40575..efc73b4 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -14,18 +14,13 @@ jobs: steps: - uses: actions/checkout@v3 - with: - submodules: 'recursive' - fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v2 with: python-version: '3.x' - - name: Update submodules - run: | - git submodule update --remote - name: Run main_quick_test.py run: | + git clone https://github.com/BA-OST-Index/ost_data.git data mkdir -p data_export python main_quick_test.py - name: Generator Dispatch From ba6f3d198f1d0c198f2da8a3122d26cbe0a3fefd Mon Sep 17 00:00:00 2001 From: sctop <2094880085@qq.com> Date: Sun, 14 Apr 2024 01:11:29 +0800 Subject: [PATCH 10/12] BREAKING-CHANGE: ignoring data_export in git --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 25ddf74..dae135d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .idea/ test*.py +/data_export/ # ----------------------------------------- # From https://github.com/github/gitignore/blob/main/Python.gitignore @@ -156,5 +157,4 @@ dmypy.json .pytype/ # Cython debug symbols -cython_debug/ -/data_export/ +cython_debug/ \ No newline at end of file From 6b17288e9bbb92f89430289c16632b936102d09b Mon Sep 17 00:00:00 2001 From: sctop <2094880085@qq.com> Date: Sun, 14 Apr 2024 01:13:44 +0800 Subject: [PATCH 11/12] BREAKING-CHANGE: removed data_export and please run --- data_export | 1 - 1 file changed, 1 deletion(-) delete mode 160000 data_export diff --git a/data_export b/data_export deleted file mode 160000 index 0c42c16..0000000 --- a/data_export +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0c42c161054d4ce547de84c53d723e22b68b697b From 3767bd6522a517a953b29a58bdd694b1ca968aa8 Mon Sep 17 00:00:00 2001 From: sctop <2094880085@qq.com> Date: Sun, 14 Apr 2024 01:15:56 +0800 Subject: [PATCH 12/12] fix(action): git clone to existing repo error --- .github/workflows/dev.yaml | 1 - .github/workflows/pull_request.yaml | 1 - .github/workflows/push.yaml | 1 - 3 files changed, 3 deletions(-) diff --git a/.github/workflows/dev.yaml b/.github/workflows/dev.yaml index 28a0c10..749b6d9 100644 --- a/.github/workflows/dev.yaml +++ b/.github/workflows/dev.yaml @@ -22,6 +22,5 @@ jobs: # Run main script to test if it can work - name: Run testing script run: | - git clone https://github.com/BA-OST-Index/ost_data.git data mkdir -p data_export python main_quick_test.py \ No newline at end of file diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 78fa185..7560bc7 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -21,6 +21,5 @@ jobs: # Run main script to test if it can work - name: Run testing script run: | - git clone https://github.com/BA-OST-Index/ost_data.git data mkdir -p data_export python main_quick_test.py \ No newline at end of file diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index efc73b4..8b178d8 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -20,7 +20,6 @@ jobs: python-version: '3.x' - name: Run main_quick_test.py run: | - git clone https://github.com/BA-OST-Index/ost_data.git data mkdir -p data_export python main_quick_test.py - name: Generator Dispatch