示例#1
0
 def __init__(self, level: int, tag: str, title: str, camera: str,
              stage: str, location: (int, str), year: str, date: str,
              time: str, clock: str, outline: str, flags: (str, list),
              note: str):
     self.level = assertion.is_int(level)
     self.tag = assertion.is_str(tag)
     self.title = assertion.is_str(title) if title else ''
     self.camera = assertion.is_str(camera) if camera else ''
     self.stage = assertion.is_str(stage) if stage else ''
     self.location = 'INT'
     self.year = assertion.is_str(year) if year else ''
     self.date = assertion.is_str(date) if date else ''
     self.time = assertion.is_str(time) if time else ''
     self.clock = assertion.is_str(clock) if clock else ''
     self.outline = assertion.is_str(outline) if outline else ''
     self.flags = []
     self.note = assertion.is_str(note) if note else ''
     if location:
         if isinstance(location, str):
             self.location = 'INT' if location.lower() in ('in',
                                                           'int') else 'EXT'
         elif isinstance(location, int):
             self.location = 'INT' if location > 0 else 'EXT'
         else:
             self.location = 'INT'
     if flags:
         if isinstance(flags, str):
             self.flags = [flags]
         else:
             self.flags = assertion.is_list(flags)
示例#2
0
文件: aliasconv.py 项目: NovelLab/sms
def apply_alias(data: list) -> list:
    assert isinstance(data, list)

    # TODO: 現在はそのシーンのみでAlias置換を行っているが、レベルが深くなっても維持するように変更する

    tmp = []
    alias = {}

    for record in data:
        assert isinstance(record, BaseCode)
        if isinstance(record, SceneInfo):
            tmp.append(record)
        elif isinstance(record, SceneEnd):
            tmp.append(record)
            alias = {}
        elif isinstance(record, Instruction) and InstType.ALIAS is record.type:
            tokens = assertion.is_list(record.args)
            alias[tokens[0]] = tokens[2]
        elif isinstance(record, Action):
            ret = TagConv.apply_alias_to_action(record,
                                                dict_sorted(alias, True))
            tmp.append(ret)
        else:
            tmp.append(record)

    logger.debug(
        msg.PROC_MESSAGE.format(proc=f"completed apply alias: {PROC}"))

    return tmp
示例#3
0
 def __init__(self,
              type: ActType,
              subject: str,
              outline: str,
              descs: list = None,
              note: str = None):
     self.type = assertion.is_instance(type, ActType)
     self.subject = assertion.is_str(subject)
     self.outline = assertion.is_str(outline)
     self.descs = assertion.is_list(descs) if descs else []
     self.note = assertion.is_str(note) if note else ''
示例#4
0
    def inherited(
        self,
        type: ActType = None,
        subject: str = None,
        outline: str = None,
        descs: list = None,
        note: str = None,
    ) -> Action:

        return Action(
            assertion.is_instance(type, ActType) if type else self.type,
            assertion.is_str(subject) if subject else self.subject,
            assertion.is_str(outline) if outline else self.outline,
            assertion.is_list(descs) if descs else self.descs,
            assertion.is_str(note) if note else self.note,
        )
示例#5
0
文件: dbmanager.py 项目: NovelLab/sms
def get_srcs_db() -> SrcsDB:

    _PROC = f"{PROC}: get sources db"
    logger.debug(msg.PROC_START.format(proc=_PROC))

    db = SrcsDB()
    key_cache = []

    paths = get_filepaths_in(PM.get_src_dir_path(), EXT_MARKDOWN, True)

    for path in paths:

        if not is_exists_path(path):
            logger.warning(
                msg.ERR_FAIL_MISSING_DATA.format(
                    data=f"source data of {path}: {PROC}"))
            continue

        data = read_file(path)
        raws = assertion.is_list(raw_src_objects_from(data))
        for raw in raws:
            if raw:
                assert isinstance(raw, RawSrc)
                if raw.tag in key_cache:
                    logger.warning(
                        msg.ERR_FAIL_DUPLICATED_DATA_WITH_DATA.format(
                            data=f"tag name: {_PROC}"), raw.tag)
                    continue
                db.add(raw.tag, raw)
                key_cache.append(raw.tag)
                logger.debug(
                    msg.PROC_MESSAGE.format(
                        proc=f"Add '{raw.tag}' to srcs db"))

    logger.debug(msg.PROC_SUCCESS.format(proc=_PROC))

    return db
示例#6
0
def test_assertion_is_list__failure(x):

    with pytest.raises(AssertionError):
        is_list(x)
示例#7
0
def test_assertion_is_list(x):

    assert is_list(x) or is_list(x) == [], f"Expected a list type value: {x}"
示例#8
0
 def __init__(self, data: list):
     self.data = assertion.is_list(data)
示例#9
0
 def __init__(self, type: InstType, args: list = None, note: str = None):
     self.type = assertion.is_instance(type, InstType)
     self.args = assertion.is_list(args) if args else []
     self.note = assertion.is_str(note) if note else ''