From 1059847075819986b93cf59b1029b4f03d6e6b89 Mon Sep 17 00:00:00 2001 From: Evgeniy Kozlov Date: Sat, 12 Oct 2024 22:11:53 +0300 Subject: [PATCH] tools: tu-deck-grabber: grab: support suffixes --- tools/tu-deck-grabber.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/tu-deck-grabber.py b/tools/tu-deck-grabber.py index 0e0b69a9..829c9bbd 100755 --- a/tools/tu-deck-grabber.py +++ b/tools/tu-deck-grabber.py @@ -785,7 +785,7 @@ def doHuntAndEnrichUserDb(client): os.renames(tmp_udb_fname, udb_fname) print('INFO: user-db: synced to disk: {} (total {} entries)'.format(udb_fname, user_db.size())) -def doGrabLastDeck(client): +def doGrabLastDeck(client, *custom_suffix): global orig_res res = orig_res = client.getBattleResults() if (not res) or ('battle_data' not in res): @@ -850,6 +850,7 @@ def doGrabLastDeck(client): # deck header enemy_guild_name = enemy_udb_entry and enemy_udb_entry.guild_name or '__UNKNOWN__' out = '' + fmt_name = lambda n: re.sub(r'(?a)[^\w]', '_', n) if config.getboolean('CORE', 'output_game_type'): out += game_type + '.' if config.getboolean('CORE', 'output_timestamp'): @@ -867,12 +868,14 @@ def doGrabLastDeck(client): if config.getboolean('CORE', 'output_eds'): out += 'eds{:02d}.'.format(enemy_size) if config.getboolean('CORE', 'output_guild'): - out += re.sub(r'(?a)[^\w]', '_', enemy_guild_name) + '.' - out += re.sub(r'(?a)[^\w]', '_', enemy_name) + out += fmt_name(enemy_guild_name) + '.' + out += fmt_name(enemy_name) if config.getboolean('CORE', 'output_missing'): missing_cards = enemy_size - enemy_played_cards_count if (missing_cards > 0): out += '.m{}'.format(missing_cards) + if custom_suffix: + out += '.' + '.'.join(fmt_name(x) for x in custom_suffix) out += ': ' # append commander @@ -1328,7 +1331,7 @@ def write_dump_safe(name, data, append = False): print(f' * Stamina: {ud["stamina"]}') print(f' * SP: {ud["salvage"]}') elif (args[0] == 'grab'): - doGrabLastDeck(client) + doGrabLastDeck(client, *args[1:]) elif (args[0] == 'hunt'): doHuntAndEnrichUserDb(client) elif (args[0] == 'fuse'):