def construct_from_sgfinfo(self, info): if "bname" in info: self.bname = info["bname"] else: self.bname = "Unknown" if "wname" in info: self.wname = info["wname"] else: self.wname = "Unknown" if "brank" in info: self.brank = "(" + info["brank"] + ")" if "wrank" in info: self.wrank = "(" + info["wrank"] + ")" if "result" in info: result = info["result"] if result[0] in ["w", "W"]: self.wname = embolden(self.wname) elif result[0] in ["b", "B"]: self.bname = embolden(self.bname) self.result = info["result"] else: self.result = "?" if "date" in info: self.date = info["date"] else: self.date = "---" if "filepath" in info: self.filepath = info["filepath"] return self
def construct_from_sgfinfo(self,info): if 'bname' in info: self.bname = info['bname'] else: self.bname = 'Unknown' if 'wname' in info: self.wname = info['wname'] else: self.wname = 'Unknown' if 'brank' in info: self.brank = '(' + info['brank'] + ')' if 'wrank' in info: self.wrank = '(' + info['wrank'] + ')' if 'result' in info: result = info['result'] if result[0] in ['w','W']: self.wname = embolden(self.wname) elif result[0] in ['b','B']: self.bname = embolden(self.bname) self.result = info['result'] else: self.result = '?' if 'date' in info: self.date = info['date'] else: self.date = '---' if 'filepath' in info: self.filepath = info['filepath'] return self
def games_args_converter(ri, game): info = {} info['sgf'] = game collection_list = list( Collection.select().join(CollectionSgf).join(Sgf).where( Sgf.id == game.id)) if len(collection_list) > 0: info['collection'] = collection_list[0] if game.filename: info['filepath'] = game.filename if game.result: info['result'] = game.result winner = game.result[0].lower() else: winner = '' if game.wname: info['wname'] = game.wname if winner == 'w': info['wname'] = embolden(info['wname']) else: info['wname'] = 'unknown' if game.bname: info['bname'] = game.bname if winner == 'b': info['bname'] = embolden(info['bname']) else: info['bname'] = 'unknown' if game.date: info['date'] = game.date if hasattr(game, 'boardname'): info['boardname'] = game.boardname return info
def games_args_converter(ri, game): info = {} info['sgf'] = game collection_list = list(Collection.select().join(CollectionSgf).join(Sgf).where(Sgf.id == game.id)) if len(collection_list) > 0: info['collection'] = collection_list[0] if game.filename: info['filepath'] = game.filename if game.result: info['result'] = game.result winner = game.result[0].lower() else: winner = '' if game.wname: info['wname'] = game.wname if winner == 'w': info['wname'] = embolden(info['wname']) if game.bname: info['bname'] = game.bname if winner == 'b': info['bname'] = embolden(info['bname']) if game.date: info['date'] = game.date return info
def construct_from_sgfinfo(self, info): if 'bname' in info: self.bname = info['bname'] else: self.bname = 'Unknown' if 'wname' in info: self.wname = info['wname'] else: self.wname = 'Unknown' if 'brank' in info: self.brank = '(' + info['brank'] + ')' if 'wrank' in info: self.wrank = '(' + info['wrank'] + ')' if 'result' in info: result = info['result'] if result[0] in ['w', 'W']: self.wname = embolden(self.wname) elif result[0] in ['b', 'B']: self.bname = embolden(self.bname) self.result = info['result'] else: self.result = '?' if 'date' in info: self.date = info['date'] else: self.date = '---' if 'filepath' in info: self.filepath = info['filepath'] return self
def info_for_button(self): info = self.gameinfo info['collection'] = self.collection info['filepath'] = self.filen info['collectionsgf'] = self try: result = info['result'] winner = result[0] if winner in ['B','b']: info['bname'] = embolden(info['bname']) elif winner in ['W','w']: info['wname'] = embolden(info['wname']) except (KeyError, IndexError): pass # If one of these keys doesn't exist, just don't modify anything return info
def info_for_button(self): info = self.gameinfo info["collection"] = self.collection info["filepath"] = self.filen info["collectionsgf"] = self try: result = info["result"] winner = result[0] if winner in ["B", "b"]: info["bname"] = embolden(info["bname"]) elif winner in ["W", "w"]: info["wname"] = embolden(info["wname"]) except (KeyError, IndexError): pass # If one of these keys doesn't exist, just don't modify anything return info
def info_for_button(self): info = self.gameinfo info['collection'] = self.collection info['filepath'] = self.filen info['collectionsgf'] = self try: result = info['result'] winner = result[0] if winner in ['B', 'b']: info['bname'] = embolden(info['bname']) elif winner in ['W', 'w']: info['wname'] = embolden(info['wname']) except (KeyError, IndexError): pass # If one of these keys doesn't exist, just don't modify anything return info