def buildvalid(self): # インポート部分 from basemods import Holder from iotemp import Template for v in self.propts: # Thing.name のテンプレート処理 - list編 if v not in Holder.master('Thing').keys(): idx = self.propts.index(v) del self.propts[idx] try: tname = Template.holder[self.group][Holder.classt( 'Thing')][v] self.propts.insert(idx, tname) except Exception: print('TEMPLATEERROR: Role.propts -{0}-'.format(self.name)) for v in self.routes: # Route.name のテンプレート処理 - list編 if v not in Holder.master('Route').keys(): idx = self.routes.index(v) del self.routes[idx] try: tname = Template.holder[self.group][Holder.classt( 'Route')][v] self.routes.insert(idx, tname) except Exception: print('TEMPLATEERROR: Role.routes -{0}- v={1}, idx={2}'. format(self.name, v, idx))
def buildvalid(self): # インポート部分 from basemods import Holder from iotemp import Template # Param.name のテンプレート処理 - scala編 if self.gtarget not in Holder.master('Param').keys(): try: self.gtarget = Template.holder[self.group][Holder.classt('Param')][self.gtarget] except Exception: print('TEMPLATEERROR: Process.gtarget -{0}-'.format(self.name)) # Param.name のテンプレート処理 - scala編 if self.gsbj_param not in Holder.master('Param').keys(): try: self.gsbj_param = Template.holder[self.group][Holder.classt('Param')][self.gsbj_param] except Exception: print('TEMPLATEERROR: Process.gsbj_param -{0}-'.format(self.name)) # Param.name のテンプレート処理 - scala編 if self.gobj_param not in Holder.master('Param').keys(): try: self.gobj_param = Template.holder[self.group][Holder.classt('Param')][self.gobj_param] except Exception: print('TEMPLATEERROR: Process.gobj_param -{0}-'.format(self.name))
def dumprolething(): if type(self.trpgobj) is Holder.classt('Thing'): self.argdic['name'] = self.trpgobj.name self.argdic['params'] = self.trpgobj.params self.argdic['propts'] = self.trpgobj.propts elif type(self.trpgobj) is Holder.classt('Role'): self.argdic['name'] = self.trpgobj.name self.argdic['propts'] = self.trpgobj.propts self.argdic['params'] = self.trpgobj.params
def buildvalid(self): # インポート部分 from basemods import Holder from iotemp import Template # Process.name のテンプレート処理 - scala編 if self.procs not in Holder.master('Process').keys(): try: self.procs = Template.holder[self.group][Holder.classt( 'Process')][self.procs] except Exception: print('TEMPLATEERROR: Event.procs') lis_role = list(self.role) for v in lis_role: # Role.name のテンプレート処理 - tuple編 if v not in Holder.master('Role').keys(): idx = lis_role.index(v) del lis_role[idx] try: tname1 = Template.holder[self.group][Holder.classt( 'Role')][v] except Exception: tname1 = '' print('TEMPLATEERROR: Event.role -{0}- v={1}, idx={2}'. format(self.name, v, idx)) lis_role.insert(idx, tname1) self.role = tuple(lis_role) lis_thing = list(self.thing) for v in lis_thing: # Thing.name のテンプレート処理 - tuple編 if v not in Holder.master('Thing').keys(): idx = lis_thing.index(v) del lis_thing[idx] try: tname2 = Template.holder[self.group][Holder.classt( 'Thing')][v] except Exception: tname2 = '' print('TEMPLATEERROR: Event.thing -{0}- v={1}, idx={2}'. format(self.name, v, idx)) lis_thing.insert(idx, tname2) self.thing = tuple(lis_thing) if len(self.role) != 2: raise TrpgError('引数 -{0}- のリストサイズが2ではありません'.format('role')) if len(self.thing) != 2: raise TrpgError('引数 -{0}- のリストサイズが2ではありません'.format('thing'))
def buildvalid(self): # インポート部分 from basemods import Holder from iotemp import Template for k in list(self.route.keys()): # delしているのでgeneratorでなくしてやる # int の Dice テンプレート処理 'xdy+z' - dict*tuple編 lis_route = list(self.route[k]) for i, v in zip(range(len(lis_route)), lis_route): if type(v) is str and v != 'next': lis_route[i] = Dice.makedice(lis_route[i]) self.route[k] = tuple(lis_route) # Route.name のテンプレート処理 - dict編 if k not in Route.master.keys(): value = self.route[k] del self.route[k] try: tname = Template.holder[self.group][Route][k] self.route[tname] = value except Exception: print('TEMPLATEERROR: Route.route -{0}- k={1}, value={2}'. format(self.name, k, value)) # Event.name のテンプレート処理 - scala編 if self.gevent not in Holder.master('Event').keys(): try: self.gevent = Template.holder[self.group][Holder.classt( 'Event')][self.gevent] except Exception: print('TEMPLATEERROR: Route.gevent -{0}-'.format(self.name)) # int の Dice テンプレート処理 'xdy+z' - scala編 if type(self.prev) is str: self.prev = Dice.makedice(self.prev)
def buildvalid(self): # インポート部分 from basemods import Holder from iotemp import Template for k in list(self.params.keys()): # delしているのでgeneratorでなくしてやる # int の Dice テンプレート処理 'xdy+z' - dict編 if type(self.params[k]) is str: self.params[k] = Dice.makedice(self.params[k]) # Param.name のテンプレート処理 - dict編 if k not in Holder.master('Param').keys(): value = self.params[k] del self.params[k] try: tname = Template.holder[self.group][Holder.classt( 'Param')][k] self.params[tname] = value except Exception: print('TEMPLATEERROR: Thing.params -{0}-'.format( self.name)) # Thing.name のテンプレート処理 - list編 for v in self.propts: if v not in Thing.master.keys(): idx = self.propts.index(v) del self.propts[idx] try: tname = Template.holder[self.group][Thing][v] self.propts.insert(idx, tname) except Exception: print('TEMPLATEERROR: Thing.propts -{0}-'.format( self.name))
def class_out(cls): # インポート部分 from basemods import Holder classts = ('Param', 'Thing', 'Process', 'Event', 'Route', 'Role') Scenario.candi = [Holder.classt(c) for c in classts] return (Scenario.candi, 'クラスを選んでください', True)
def action_in(self, act): """ Request In """ # インポート部分 from basemods import Holder if act is None: act = self.getroutes()[0] self.act = act if type(act) is Holder.classt('Route'): return { 'curr_func': self.way_node, 'arg': (act, ), 'next_func': self.way_in } else: return { 'curr_func': self.focus_out_thing, 'arg': (), 'next_func': self.focus_in_thing }
def check_in(self, s_name, tmpl, desc, opted): # インポート部分 from basemods import Holder tmpls = tmpl.split('-') typet = tmpls[0] numbt = None if len(tmpls) > 1: numbt = int(tmpls[1]) # tuple 定数a, list 無制限=0, dict 無制限=0の場合 if numbt < 1 or 100 < numbt: numbt = 100 if typet == 'str': if s_name == 'name': if self.name != '': rtn = self.name else: rtn = opted # 更新の場合 if rtn in list(self.classt.master.keys()): self.existclss = self.classt.master[rtn] else: rtn = opted elif typet == 'int': try: rtn = int(opted) except ValueError as e: if Dice.checkdice(rtn) > 0: print('MESSAGE: ダイス形式で設定') rtn = opted else: print('Exception: {0}'.format(e)) rtn = 0 elif typet == 'bool': rtn = bool(opted) elif typet == 'tuple': self.tlis = list(opted) rtn = tuple(self.tlis) elif typet == 'list': self.tlis = list(opted) rtn = self.tlis elif typet == 'dict': keyt = opted valt = opted self.tlis.append((keyt, valt)) rtn = dict(self.tlis) else: rtn = opted tt = typet.split('.') classtnames = ('Param', 'Thing', 'Process', 'Event', 'Route', 'Role') if tt[0] in classtnames: s_classt = Holder.classt(tt[0]) if tt[1] == 'name': s_candi = list(s_classt.master.keys()) elif tt[1] == 'deed': gg = getmembers(s_classt, isfunction) s_candi = [g[0] for g in gg] if tt[1] == 'name' and rtn not in s_candi: t = Template(s_classt, self.group, rtn) print('グループ -{0}- > クラス -{1}- > テンプレート -{2}- を作成しました'.format(self.group, s_classt.__name__, rtn)) t.holdermap(self.group, s_classt, rtn) if self.existclss is not None: if rtn == '': default = getattr(self.existclss, s_name) if type(default) in (int, str, bool): rtn = default else: raise TrpgError('デフォルトを設定します') setattr(self.existclss, s_name, rtn)
def check_out(self, s_name, tmpl, desc): # インポート部分 from basemods import Holder def outputu(desc, typet, candi=list(), numbt=None): default = None try: if self.existclss is not None: default = getattr(self.existclss, s_name) # message = '{0}({1}): {2} (default: {3})'.format(desc, s_name, typet, default) # (型, 候補リスト, 繰り返し回数, 入力領域, デフォルト) return (typet, candi, numbt, list(), default) except TrpgError as e: raise e tmpls = tmpl.split('-') typet = tmpls[0] valut = '' numbt = None if len(tmpls) > 1: numbt = int(tmpls[1]) # tuple 定数a, list 無制限=0, dict 無制限=0の場合 if numbt < 1 or 100 < numbt: numbt = 100 valut = '-'.join(tmpls[2:]) if typet == 'str': if s_name == 'name': if self.name == '': print('UPDATE IN {0}'.format(list(self.classt.master.keys()))) return outputu(desc, typet) else: return outputu(desc, typet) elif typet == 'int': return outputu(desc, typet) elif typet == 'bool': return outputu(desc, typet) elif typet == 'tuple': return outputu(desc, 'tuple', self.check_out(s_name, valut, desc), numbt) elif typet == 'list': return outputu(desc, 'list', self.check_out(s_name, valut, desc), numbt) elif typet == 'dict': tt = valut.split(':') tt0 = self.check_out(s_name, tt[0], desc) tt1 = self.check_out(s_name, tt[1], desc) return outputu(desc, 'dict', (tt0, tt1), numbt) else: tt = typet.split('.') classtnames = ('Param', 'Thing', 'Process', 'Event', 'Route', 'Role') if tt[0] in classtnames: s_classt = Holder.classt(tt[0]) if tt[1] == 'name': s_candi = list(s_classt.master.keys()) elif tt[1] == 'deed': gg = getmembers(s_classt, isfunction) s_candi = [g[0] for g in gg] print('SELECT IN {0}'.format(s_candi)) return outputu(desc, typet, s_candi)