def update_helper(char_name, move_nodes): print('updating moves for', char_name) char = Database.Characters(char_name) start = Database.raw_moves[char] count = 0 if True: (key_in, key_out) = -1, 0 key_to_val = {i.name: str(i.move_id) for i in move_nodes} else: (key_in, key_out) = 0, -1 key_to_val = {str(i.move_id): i.name for i in move_nodes} for row in start[1:]: val_in = row[key_in].split(',') val_out = ','.join( [j for j in [key_to_val.get(i) for i in val_in] if j]) check_out = row[key_out] if check_out != val_out: count += 1 row[key_out] = val_out print('diff', count) if count > 0: csv_content = '\n'.join(['\t'.join(i) for i in start]) + '\n' path = Path.path('./database/%s.csv' % char.name) with open(path, 'w', encoding='UTF-8') as fh: fh.write(csv_content) print('done')
def populate_character(character_name): existing = [i for i in database.keys() if i[0] == character_name] for i in existing: del database[i] path = Path.path('./database/%s.csv' % character_name) with open(path, encoding='UTF-8') as csvfile: reader = csv.reader(csvfile, delimiter='\t') data = [i for i in reader if i] raw_moves[Characters[character_name]] = data header = data[0] for move in data[1:]: populate_move(character_name, header, move)
def init_tk(self): self.wm_title("dcep93/TekkenBot") self.iconbitmap(Path.path('./img/tekken_bot_close.ico')) self.text = t_tkinter.Text(self, wrap="word") stdout = sys.stdout sys.stdout = TextRedirector(self.text, stdout, "stdout") stderr = sys.stderr sys.stderr = TextRedirector(self.text, stderr, "stderr") self.text.tag_configure("stderr", foreground="#b22222") self.text.pack(fill=t_tkinter.BOTH) self.geometry('1200x420+0+0')
def get_path(file_name=RAW_PATH): return Path.path('./record/%s' % file_name)