Example #1
0
 def network_insert(self, network):
     json = network.json()
     self.__augment_json(json, 'networks')
     # Inserting that dictionary if absent is a PAIN with
     # DynamoDB. Always include it.
     json.setdefault('endpoints', {})
     self.__put_duplicate(json, infinit.beyond.Network.Duplicate)
Example #2
0
 def __init__(self, json):
     global nameSentou
     global nameTansaku
     global nameKoudou
     global nameKoushou
     global nameChishiki
     self.gamemode = json['game']
     self.name = json['pc_name']  #名前
     self.shuzoku = json['shuzoku']  #職業
     self.age = json['age']  #年齢
     self.sex = json['sex']  #性別
     self.memo = json['pc_making_memo']  #メモ
     self.str = json['NP1']
     self.con = json['NP2']
     self.pow = json['NP3']
     self.dex = json['NP4']
     self.app = json['NP5']
     self.siz = json['NP6']
     self.int = json['NP7']
     self.edu = json['NP8']
     self.hp = json['NP9']
     self.mp = json['NP10']
     self.luck = json['NP11']
     self.know = json['NP12']
     self.san = json['SAN_Left']  #現在SAN
     self.sanMax = json['SAN_Max']  #最大SAN
     self.sanDenger = json['SAN_Danger']  #発狂SAN
     self.baseSentou = json['TBAD']  #初期値-戦闘技能
     self.totalSentou = json['TBAP']  #合計値-戦闘技能
     self.baseTansaku = json['TFAD']  #初期値-探索技能
     self.totalTansaku = json['TFAP']  #合計値-探索技能
     self.baseKoudou = json['TAAD']  #初期値-行動技能
     self.totalKoudou = json['TAAP']  #合計値-行動技能
     self.baseKoushou = json['TCAD']  #初期値-交渉技能
     self.totalKoushou = json['TCAP']  #合計値-交渉技能
     self.baseChishiki = json['TKAD']  #初期値-知識技能
     self.totalChishiki = json['TKAP']  #合計値-知識技能
     self.untenKoudou = json['unten_bunya']
     self.seisakuKondou = json['seisaku_bunya']
     self.soujuuKoudou = json['main_souju_norimono']
     self.bokokugoKoushou = json['mylang_name']
     self.geijutuChishiki = json['geijutu_bunya']
     json.setdefault('TBAName', [])
     json.setdefault('TFAName', [])
     json.setdefault('TAAName', [])
     json.setdefault('TCAName', [])
     json.setdefault('TKAName', [])
     self.inteSentou = addGinou(nameSentou, json['TBAName'])
     self.inteTansaku = addGinou(nameTansaku, json['TFAName'])
     self.inteKoudou = addGinou(nameKoudou, json['TAAName'])
     self.inteKoushou = addGinou(nameKoushou, json['TCAName'])
     self.inteChishiki = addGinou(nameChishiki, json['TKAName'])
Example #3
0
def handle_my_custom_event(json, methods=['GET', 'POST']):
    socketio.emit('my response', json, callback=messageReceived)

    global userPhone

    if ("지출" in json.setdefault('message')
            and "입력" in json.setdefault('message')):
        userIn = botDAO.sayInput_1(-1, userPhone)
        socketio.emit('start_chat', userIn)

    if ("수입" in json.setdefault('message')
            and "입력" in json.setdefault('message')):
        userIn = botDAO.sayInput_1(1, userPhone)
        socketio.emit('start_chat', userIn)

    if ("여기까지" in json.setdefault('message')):
        botDAO.sayInput_1(0, userPhone)
        socketio.emit('start_chat', '네, 처리해 드렸습니다 :>')

    botDAO.sayInput_2(json, userPhone)
Example #4
0
    def json(self, json):
        """Updates the line from the json properties
        
        Currently very basic, in that it only really updates the status
        Everything else needs to happen later
        TODO allow updating all parts via json
        
        To make this method viable, it probably needs that the client files
        minimal update bundles, that are then applied as an update that only changes one aspect?
        Not sure how this is to work with child tasks.
        """
        # REFACT Gnarly code, not sure how to write this more beautifull

        if 'line' in json:
            self.line = json['line']

        if 'body' in json:
            self.body = json['body']

        if 'status' in json:
            json.setdefault('tags', {})['status'] = json.get('status')

        if 'id' in json:
            if json['id'] and not self.id:
                self.line += f' #{json["id"]}'
            else:
                self.edit(remove=f'#{self.id}', replace_with=f" #{json['id']}")

        if json.get('tags', {}) or self.tags:
            for existing_key, existing_value in self.tags.items():
                if existing_key not in json.get(
                        'tags', {}) or existing_value != json.get(
                            'tags', {}).get(existing_key):
                    self.edit(remove=f'{existing_key}:{existing_value}'
                              )  # FIXME handle quoting

            existing_tags = self.tags
            for key, value in json.get('tags', {}).items():
                if key not in existing_tags:
                    self.line += f' {key}:{value}'  # FIXME handle quoting

            # normalize status tags
            if self.has_tags('status:new'):
                self.edit(remove='status:new')

            if self.has_tags('status:done'):
                self.edit(remove='status:done')
                json['is_done'] = True

        # REFACT Could be that it is signifficantly easier to just reflect the status
        # as it's own syntactic ting instead of hijacking tags
        if 'is_done' in json:
            if json['is_done'] and not self.is_done:
                self.line = re.sub(r'(^\s*)(.*$)', r'\1x \2', self.line)
            elif not json['is_done'] and self.is_done:
                self.line = re.sub(r'(^\s*)x\s+\b(.*$)', r'\1\2', self.line)

        if json.get('children', []):
            json_children = json.get('children', [])

            if len(json_children) > len(self.children):
                for _ in range((len(json_children) - len(self.children))):
                    self.children.append(Todo())
            elif len(json_children) < len(self.children):
                self.children = self.children[:len(json_children)]

            for child, child_json in zip(self.children, json_children):
                child.json = child_json
 def _repr_json_(self):
     json = self._tabwidget._repr_json_()
     json.setdefault('properties', {}).update(self.properties())
     json['interface'] = 'IAppletContainer'
     return json
Example #6
0
 def _repr_json_(self):
     json = self._tabwidget._repr_json_()
     json.setdefault('properties', {}).update(self.properties())
     return json
Example #7
0
 def _repr_json_(self):
     json = self._tabwidget._repr_json_()
     json.setdefault('properties', {}).update(self.properties())
     json['interface'] = 'IAppletContainer'
     return json