From c830955b6fe7b11f3d50bd2a0ce8eb0aefaa39c9 Mon Sep 17 00:00:00 2001 From: Jylpah Date: Thu, 26 Nov 2020 21:29:17 +0200 Subject: [PATCH] add _id to replays JSON read from the filesystem --- analyze_wotb_replays.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/analyze_wotb_replays.py b/analyze_wotb_replays.py index 1165345..e54925c 100755 --- a/analyze_wotb_replays.py +++ b/analyze_wotb_replays.py @@ -1960,7 +1960,7 @@ async def mk_replayQ(queue : asyncio.Queue, args : argparse.Namespace, db : moto if not line: break if (p_replayfile.match(line) != None): - replay_json = await bu.open_JSON(line, wi.chk_JSON_replay) + replay_json = await bu.open_JSON(line, wi.chk_JSON_replay) await queue.put(await mk_readerQ_item(replay_json, line)) except Exception as err: bu.error(exception=err) @@ -1993,7 +1993,13 @@ async def mk_replayQ(queue : asyncio.Queue, args : argparse.Namespace, db : moto async def mk_readerQ_item(replay_json, filename : str = None) -> list: """Make an item to replay queue""" global REPLAY_N - REPLAY_N +=1 + REPLAY_N +=1 + try: + if not '_id' in replay_json: + id = wi.read_replay_id(replay_json) + replay_json['_id'] = id + except Exception as err: + bu.error(exception=err) if filename == None: return [replay_json, REPLAY_N, '' ] elif RE_SRC_IS_DB.match(filename) != None: