def scene_transition_data_from(infos_data: InfosData) -> InfosData: assert isinstance(infos_data, InfosData) logger.debug(msg.PROC_START.format(proc=PROC)) tmp = [] cache = SceneInfo() tmp.append(get_record_as_splitter()) tmp.append( InfoRecord(InfoType.DATA_TITLE, ActType.DATA, '## SCENE TRANSITIONS', '', '')) for record in infos_data.get_data(): assert isinstance(record, InfoRecord) if InfoType.SCENE_HEAD is record.type: tmp.append(_record_of_scene_transition_from(record, cache)) tmp.append( InfoRecord(InfoType.SCENE_TRANSITION, record.act, record.subject, record.outline, record.note)) cache = record.note elif InfoType.TITLE_EPISODE is record.type: tmp.append(_get_record_as_transition_split()) elif InfoType.TITLE_SCENE is record.type: continue else: continue logger.debug(msg.PROC_SUCCESS.format(proc=PROC)) return InfosData(tmp)
def _get_record_as_data_splitter(elm: ElmType) -> InfoRecord: assert isinstance(elm, ElmType) if ElmType.PERSON is elm: return InfoRecord(InfoType.PERSON_STATE_INFO, ActType.DATA, '', '', PersonStateInfo(PersonStateType.NONE, 0, '', '', '')) else: return InfoRecord(InfoType.STAGE_STATE_INFO, ActType.DATA, '', '', StageStateInfo(StageStateType.NONE, 0, '', '', ''))
def _record_as_action_from(record: ActionRecord) -> InfoRecord: return InfoRecord( InfoType.ACTION, record.type, record.subject, record.outline, record.note)
def _record_as_foreshadow_from(record: ActionRecord) -> InfoRecord: assert isinstance(record, ActionRecord) return InfoRecord( InfoType.FLAG_FORESHADOW, ActType.DATA, record.subject, record.outline, record.note)
def _record_as_comment_from(record: ActionRecord) -> InfoRecord: assert isinstance(record, ActionRecord) return InfoRecord( InfoType.COMMENT, ActType.DATA, record.subject, record.outline, record.note)
def _record_as_title_from(record: ActionRecord) -> InfoRecord: assert isinstance(record, ActionRecord) return InfoRecord( _title_from(record), ActType.DATA, record.subject, record.outline, record.note)
def _record_as_payoff_from(record: ActionRecord) -> InfoRecord: assert isinstance(record, ActionRecord) return InfoRecord( InfoType.FLAG_PAYOFF, ActType.DATA, record.subject, record.outline, record.note)
def _record_as_flag_info_from(record: InfoRecord, index: int, flag_type: FlagType) -> InfoRecord: assert isinstance(record, InfoRecord) assert isinstance(index, int) assert isinstance(flag_type, FlagType) return InfoRecord( InfoType.FLAG_INFO, ActType.DATA, '', '', FlagInfo(flag_type, index, record.subject, record.outline, record.note))
def _record_as_fashion_info_from(index: int, record: InfoRecord) -> InfoRecord: assert isinstance(index, int) assert isinstance(record, InfoRecord) if ActType.WEAR is record.act: info = FashionInfo(index, record.subject, record.outline, record.note) return InfoRecord(InfoType.FASHION_INFO, record.act, record.subject, record.outline, info) else: return None
def _update_tags_action_record(record: InfoRecord, tags: dict, callings: dict) -> InfoRecord: assert isinstance(record, InfoRecord) assert isinstance(tags, dict) assert isinstance(callings, dict) if record.subject in callings: calling = dict_sorted(callings[record.subject], True) return InfoRecord( record.type, record.act, translate_tags_str(record.subject, tags, True, None), translate_tags_str(record.outline, calling), translate_tags_str(record.note, calling), ) else: return InfoRecord( record.type, record.act, translate_tags_str(record.subject, tags, True, None), record.outline, record.note, )
def _record_as_item_info_from(index: int, record: InfoRecord) -> InfoRecord: assert isinstance(index, int) assert isinstance(record, InfoRecord) info_type = ItemInfoType.NONE if ActType.HAVE is record.act: info_type = ItemInfoType.HAVE elif ActType.DISCARD is record.act: info_type = ItemInfoType.DISCARD else: return None return InfoRecord( InfoType.ITEM_INFO, record.act, record.subject, record.outline, ItemInfo(info_type, index, record.subject, record.outline, record.note))
def _update_tags_scene_head_record(record: InfoRecord, tags: dict) -> InfoRecord: assert isinstance(record, InfoRecord) assert isinstance(tags, dict) info = assertion.is_instance(record.note, SceneInfo) _info = SceneInfo() _info.camera = translate_tags_str(info.camera, tags, True, None) _info.stage = translate_tags_str(info.stage, tags, True, None) _info.year = translate_tags_str(str(info.year), tags, True, None) _info.date = translate_tags_str(str(info.date), tags, True, None) _info.time = translate_tags_str(str(info.time), tags, True, None) return InfoRecord( record.type, record.act, record.subject, record.outline, _info)
def _record_as_person_info_from(index: int, record: InfoRecord) -> InfoRecord: assert isinstance(index, int) assert isinstance(record, InfoRecord) info_type = PersonInfoType.NONE if ActType.BE is record.act: info_type = PersonInfoType.BE elif ActType.COME is record.act: info_type = PersonInfoType.COME elif ActType.GO is record.act: info_type = PersonInfoType.GO else: return None info = PersonInfo(info_type, index, record.subject, record.outline) return InfoRecord(InfoType.PERSON_INFO, record.act, record.subject, record.outline, info)
def _record_as_knowledge_info_from(index: int, record: InfoRecord) -> InfoRecord: assert isinstance(index, int) assert isinstance(record, InfoRecord) info_type = KnowledgeInfoType.NONE if ActType.EXPLAIN is record.act: info_type = KnowledgeInfoType.EXPLAIN elif ActType.KNOW is record.act: info_type = KnowledgeInfoType.KNOW elif ActType.KNOWN is record.act: info_type = KnowledgeInfoType.KNOWN elif ActType.REMEMBER is record.act: info_type = KnowledgeInfoType.REMEMBER else: return None return InfoRecord( InfoType.KNOWLEDGE_INFO, ActType.DATA, record.subject, record.outline, KnowledgeInfo(info_type, index, record.subject, record.outline, record.note))
def _record_as_stage_info_from(index: int, stage: str, record: InfoRecord) -> InfoRecord: assert isinstance(index, int) assert isinstance(stage, str) assert isinstance(record, InfoRecord) info_type = StageInfoType.NONE if ActType.DRAW is record.act: info_type = StageInfoType.DRAW elif ActType.PUT is record.act: info_type = StageInfoType.PUT elif ActType.RID is record.act: info_type = StageInfoType.RID else: return None info = StageInfo(info_type, index, stage, record.subject, record.outline, record.note) return InfoRecord(InfoType.STAGE_INFO, record.act, record.subject, record.outline, info)
def _record_of_scene_transition_from(record: InfoRecord, cache: SceneInfo) -> InfoRecord: assert isinstance(record, InfoRecord) assert isinstance(cache, SceneInfo) def _diff(a: str, b: str) -> str: if a != b: return '↓' else: return '…' base = assertion.is_instance(record.note, SceneInfo) dif = SceneInfo() dif.camera = _diff(base.camera, cache.camera) dif.stage = _diff(base.stage, cache.stage) dif.year = _diff(base.year, cache.year) dif.date = _diff(base.date, cache.date) dif.time = _diff(base.time, cache.time) return InfoRecord(InfoType.SCENE_TRANSITION, ActType.DATA, '', '', dif)
def _record_as_stage_info_from(index: int, stage: str, record: InfoRecord) -> InfoRecord: assert isinstance(index, int) assert isinstance(stage, str) assert isinstance(record, InfoRecord) info_type = StageStateType.NONE subject = record.subject if ActType.DRAW is record.act: info_type = StageStateType.VIEW if not record.subject: subject = record.outline elif ActType.PUT is record.act: info_type = StageStateType.ITEM elif ActType.RID is record.act: info_type = StageStateType.ITEM else: return None return InfoRecord( InfoType.STAGE_STATE_INFO, ActType.DATA, '', '', StageStateInfo(info_type, index, stage, subject, record.note))
def _record_as_person_info_from(index: int, record: InfoRecord) -> InfoRecord: assert isinstance(index, int) assert isinstance(record, InfoRecord) info_type = PersonStateType.NONE if ActType.WEAR is record.act: info_type = PersonStateType.SKIN elif ActType.FACE is record.act: info_type = PersonStateType.SKIN elif ActType.KNOW is record.act: info_type = PersonStateType.INFO elif ActType.KNOWN is record.act: info_type = PersonStateType.INFO elif ActType.FEEL is record.act: info_type = PersonStateType.STATE else: return None info = PersonStateInfo(info_type, index, record.subject, record.outline, record.note) return InfoRecord(InfoType.PERSON_STATE_INFO, ActType.DATA, record.subject, record.outline, info)
def _get_record_as_transition_split() -> InfoRecord: line = '---' info = SceneInfo(line, line, line, line, line) return InfoRecord(InfoType.SCENE_TRANSITION, ActType.DATA, '', '', info)
def _get_record_as_splitter() -> InfoRecord: return InfoRecord(InfoType.STAGE_INFO, ActType.DATA, '', '', StageInfo(StageInfoType.NONE, -1, '', '', '', ''))
def get_record_as_splitter() -> InfoRecord: return InfoRecord(InfoType.SPLITTER, ActType.DATA, '', '', '')
def _get_record_as_splitter() -> InfoRecord: return InfoRecord(InfoType.FASHION_INFO, ActType.DATA, '', '', FashionInfo(-1, '----', '----'))
def get_record_as_data_title(title: str) -> InfoRecord: assert isinstance(title, str) return InfoRecord(InfoType.DATA_TITLE, ActType.DATA, f"## {title}", '', '')
def _get_record_as_flag_info_split() -> InfoRecord: info = FlagInfo(FlagType.NONE, 0, '', '', '') return InfoRecord(InfoType.FLAG_INFO, ActType.DATA, '', '', info)
def _get_record_as_splitter() -> InfoRecord: return InfoRecord(InfoType.ITEM_INFO, ActType.DATA, '', '', ItemInfo(ItemInfoType.NONE, -1, '', '', ''))
def _get_record_as_scene_end() -> InfoRecord: return InfoRecord(InfoType.SCENE_END, ActType.DATA, '', '', '')
def _get_record_as_splitter() -> InfoRecord: return InfoRecord(InfoType.KNOWLEDGE_INFO, ActType.DATA, '', '', KnowledgeInfo(KnowledgeInfoType.NONE, -1, '', '', ''))
def _record_as_scene_head_from(sceneinfo: SceneInfo) -> InfoRecord: assert isinstance(sceneinfo, SceneInfo) return InfoRecord(InfoType.SCENE_HEAD, ActType.DATA, '', '', sceneinfo)
def _get_record_as_data_splitter() -> InfoRecord: return InfoRecord(InfoType.PERSON_INFO, ActType.DATA, '', '', PersonInfo(PersonInfoType.NONE, 0, '', ''))