def execute(self, src: Story) -> ResultData: LOG.info('PLOT_UPDATER: start exec') tmp, is_succeeded, error = assertion.is_tuple(self._exec_internal(src)) return ResultData( assertion.is_instance(tmp, Story), is_succeeded, error)
def __init__(self, name: str, rubi: str, exclusions: tuple = None, is_always: bool = False): super().__init__(name) self._rubi = assertion.is_str(rubi) self._exclusions = assertion.is_tuple(exclusions) if exclusions else () self._is_always = assertion.is_bool(is_always)
def __init__(self, name: str, parent: str='', geometry: tuple=None, info: str=''): super().__init__(name) self._parent = assertion.is_str(parent) self._geometry = assertion.is_tuple(geometry) if geometry else (0,0) self._info = assertion.is_str(info)
def test_is_tuple(self): data = [ # (val, expect) (True, (1,2,3), (1,2,3),), (False, 1, 1), (False, [1,2,3], [1,2,3],), ] validate_with_fail(self, "is_tuple", lambda v,expect: self.assertEqual(assertion.is_tuple(v), expect), data)
def __init__( self, src: SObject, cmd: SCmd, script: tuple, option: (int, str) = '', ): super().__init__('__scode__') self._src = assertion.is_instance(src, SObject) if src else None self._cmd = assertion.is_instance(cmd, SCmd) self._script = assertion.is_tuple(script) self._option = assertion.is_int_or_str(option)
def __init__(self, name: str, fullname: str, age: int, birth: tuple, sex: str, job: str, calling: (str, dict)='me:私', info: str=''): super().__init__(name) self._basename = assertion.is_str(fullname) self._age = assertion.is_int(age) self._birth = assertion.is_tuple(birth) self._sex = assertion.is_str(sex) self._job = assertion.is_str(job) self._calling = calling_dict_from(calling, name) self._info = assertion.is_str(info) # names self._firstname, self._lastname, self._fullname, self._exfullname = name_set_from(self._basename, name)
def _conv_from_tag(self, src: SCode, head_info: str, nums: tuple, is_comment: bool, is_plot: bool, is_data: bool, in_material: bool) -> Tuple[str, tuple]: assertion.is_str(head_info) tmp = '' ch_num, ep_num, sc_num = assertion.is_tuple(nums) if assertion.is_instance(src, SCode).cmd is SCmd.TAG_BR: tmp = '\n\n' elif src.cmd is SCmd.TAG_COMMENT: if is_comment: if src.option == 'outline': tmp = f'<!--\n【{"。".join(src.script)}】\n-->\n\n' else: if in_material: tmp = f'{"。".join(src.script)}\n' else: tmp = f'<!--{"。".join(src.script)}-->\n' elif src.cmd is SCmd.TAG_HR: tmp = '--------' * 9 elif src.cmd is SCmd.TAG_SYMBOL: tmp = f'\n{"".join(src.script)}\n\n' elif src.cmd is SCmd.TAG_TITLE: if isinstance(src.option, str) and 'contents' in src.option: if not is_plot and not is_data and src.option == 'contents:1': tmp = f'---\n# CONTENTS\n{src.script[0]}\n---\n' elif is_plot and src.option == 'contents:0': tmp = f'---\n# CONTENTS\n{src.script[0]}\n---\n' elif is_data and src.option == 'contents:2': tmp = f'---\n# CONTENTS\n{src.script[0]}\n---\n' else: head = '#' * src.option if isinstance(src.option, int) else '##' info_str = f' {head_info}' if head_info else '' title = ''.join(src.script) head_info = '' if src.option == 1: tmp = f'{head} {title}{info_str}\n\n' elif src.option == 2: tmp = f'{head} Ch-{ch_num}: {title}{info_str}\n\n' ch_num += 1 elif src.option == 3: tmp = f'{head} Ep-{ep_num}: {title}{info_str}\n\n' ep_num += 1 elif src.option == 4: tmp = f'_S-{sc_num} {title}_ {info_str}\n' sc_num += 1 else: tmp = f'\n{head} {title}\n\n' else: LOG.debug(f'Other tag: {src.cmd}') return (tmp, (ch_num, ep_num, sc_num))
def __init__(self, title: str): LOG.info('CONFIG: initialize') LOG.debug(f'-- title: {title}') # for specific self._title = assertion.is_str(title) self._copy = assertion.is_str('__catch_copy__') self._oneline = assertion.is_str('__one_line__') self._outline = assertion.is_str('__story_outline__') self._theme = assertion.is_str('__theme__') self._genre = assertion.is_str('__genre__') self._target = assertion.is_str('__target_age__') self._size = assertion.is_str('__size__') self._desc_size = assertion.is_int(0) self._total_size = assertion.is_int(0) self._desc_papers = assertion.is_int_or_float(0) self._total_papers = assertion.is_int_or_float(0) # for story self._priority = assertion.is_int(__PRIORITY_DEFAULT__) self._start = assertion.is_int(0) self._end = assertion.is_int(-1) self._base_date = datetime.date(2020, 1, 1) self._base_time = datetime.time(12, 00) self._version = assertion.is_tuple((0, 0, 1)) self._columns = assertion.is_int(20) self._rows = assertion.is_int(20) self._contest_info = assertion.is_str('') self._caution = assertion.is_str('') self._note = assertion.is_str('') self._sites = assertion.is_listlike([]) self._taginfos = assertion.is_listlike([]) self._modified = datetime.date.today() self._released = datetime.date(2020, 1, 1) # for compile self._is_data = assertion.is_bool(False) self._is_plot = assertion.is_bool(False) self._is_text = assertion.is_bool(False) self._is_scenario = assertion.is_bool(False) self._is_audiodrama = assertion.is_bool(False) self._is_rubi = assertion.is_bool(False) self._is_comment = assertion.is_bool(False) self._is_console = assertion.is_bool(False) self._format_mode = assertion.is_instance(FormatMode.DEFAULT, FormatMode) self._output_mode = assertion.is_instance(OutputMode.FILE, OutputMode) self._filename = assertion.is_str('story') self._builddir = assertion.is_str('build') self._log_level = assertion.is_str('warn')
def __init__(self, title: str, *args: Any, outline: str = ''): super().__init__(title) self._children = assertion.is_tuple(args) self._outline = assertion.is_str(outline)
def __init__(self, title: str, *args): self._title = assertion.is_str(title) self._data = assertion.is_tuple(args)