mirror of
https://github.com/Jylpah/blitz-tools.git
synced 2026-10-24 11:39:52 +02:00
ADd defaults for tankopedia and map JSON files
This commit is contained in:
1 parent
5a9f7587b9
commit
707239d75e
3 files changed
+23
-25
No files matched your search
+19
-18
@@ -32,10 +32,7 @@ def setVerbose(verbose: bool):
|
|||||||
def verbose(msg = ""):
|
def verbose(msg = ""):
|
||||||
"""Print a message"""
|
"""Print a message"""
|
||||||
if VERBOSE:
|
if VERBOSE:
|
||||||
curframe = inspect.currentframe()
|
print(msg)
|
||||||
calframe = inspect.getouterframes(curframe, 2)
|
|
||||||
caller = calframe[1][3]
|
|
||||||
print(caller + '(): ' + msg)
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def debug(msg = ""):
|
def debug(msg = ""):
|
||||||
@@ -170,20 +167,24 @@ class WG:
|
|||||||
|
|
||||||
self.WG_appID = WG_appID
|
self.WG_appID = WG_appID
|
||||||
self.tanks = None
|
self.tanks = None
|
||||||
if tankopedia_fn != None:
|
if (tankopedia_fn != None):
|
||||||
try:
|
if os.path.exists(tankopedia_fn) and os.path.isfile(tankopedia_fn):
|
||||||
with open(tankopedia_fn, 'rt', encoding='utf8') as f:
|
try:
|
||||||
self.tanks = json.loads(f.read())
|
with open(tankopedia_fn, 'rt', encoding='utf8') as f:
|
||||||
except Exception as err:
|
self.tanks = json.loads(f.read())
|
||||||
error('Could not read tankopedia: ' + tankopedia_fn + '\n' + str(err))
|
except Exception as err:
|
||||||
|
error('Could not read tankopedia: ' + tankopedia_fn + '\n' + str(err))
|
||||||
if maps_fn != None:
|
else:
|
||||||
try:
|
verbose('Could not find Tankopedia file: ' + tankopedia_fn)
|
||||||
with open(maps_fn, 'rt', encoding='utf8') as f:
|
if (maps_fn != None):
|
||||||
self.maps = json.loads(f.read())
|
if os.path.exists(maps_fn) and os.path.isfile(maps_fn):
|
||||||
except Exception as err:
|
try:
|
||||||
error('Could not read maps file: ' + maps_fn + '\n' + str(err))
|
with open(maps_fn, 'rt', encoding='utf8') as f:
|
||||||
|
self.maps = json.loads(f.read())
|
||||||
|
except Exception as err:
|
||||||
|
error('Could not read maps file: ' + maps_fn + '\n' + str(err))
|
||||||
|
else:
|
||||||
|
verbose('Could not find maps file: ' + maps_fn)
|
||||||
if self.WG_appID != None:
|
if self.WG_appID != None:
|
||||||
self.session = aiohttp.ClientSession()
|
self.session = aiohttp.ClientSession()
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ async def main(argv):
|
|||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Extract Tankopedia data from Blitz game files')
|
parser = argparse.ArgumentParser(description='Extract Tankopedia data from Blitz game files')
|
||||||
parser.add_argument('blitzAppBase', type=str, metavar="BLITZAPP_FOLDER", default=".", help='Base dir of the Blitz App files')
|
parser.add_argument('blitzAppBase', type=str, metavar="BLITZAPP_FOLDER", default=".", help='Base dir of the Blitz App files')
|
||||||
parser.add_argument('tanks', type=str, default='tanks.json',metavar="TANKS_FILE", help='File to write Tankopedia')
|
parser.add_argument('tanks', type=str, default='tanks.json', nargs='?', metavar="TANKS_FILE", help='File to write Tankopedia')
|
||||||
parser.add_argument('maps', type=str, default='maps.json', metavar='MAPS_FILE', help='File to write map names')
|
parser.add_argument('maps', type=str, default='maps.json', nargs='?', metavar='MAPS_FILE', help='File to write map names')
|
||||||
parser.add_argument('-d', '--debug', action='store_true', default=False, help='Debug mode')
|
parser.add_argument('-d', '--debug', action='store_true', default=False, help='Debug mode')
|
||||||
parser.add_argument('-v', '--verbose', action='store_true', default=False, help='Verbose mode')
|
parser.add_argument('-v', '--verbose', action='store_true', default=False, help='Verbose mode')
|
||||||
|
|
||||||
|
|||||||
@@ -31,14 +31,13 @@ async def main(argv):
|
|||||||
parser.add_argument('-t','--title', type=str, default=None, help='Title for replays. Use NN for continous numbering. Default is filename-based numbering')
|
parser.add_argument('-t','--title', type=str, default=None, help='Title for replays. Use NN for continous numbering. Default is filename-based numbering')
|
||||||
parser.add_argument('-p', '--private', dest="private", action='store_true', default=False, help='Set replays private on WoTinspector.com')
|
parser.add_argument('-p', '--private', dest="private", action='store_true', default=False, help='Set replays private on WoTinspector.com')
|
||||||
parser.add_argument('--tasks', dest='N_tasks', type=int, default=10, help='Number of worker threads')
|
parser.add_argument('--tasks', dest='N_tasks', type=int, default=10, help='Number of worker threads')
|
||||||
parser.add_argument('--tankopedia', type=str, default=None, help='JSON file to read Tankopedia from')
|
parser.add_argument('--tankopedia', type=str, default='tanks.json', help='JSON file to read Tankopedia from. Default: "tanks.json"')
|
||||||
parser.add_argument('--mapfile', type=str, default=None, help='JSON file to read Blitz map names from')
|
parser.add_argument('--mapfile', type=str, default='maps.json', help='JSON file to read Blitz map names from. Default: "maps.json"')
|
||||||
parser.add_argument('-d', '--debug', action='store_true', default=False, help='Debug mode')
|
parser.add_argument('-d', '--debug', action='store_true', default=False, help='Debug mode')
|
||||||
parser.add_argument('-v', '--verbose', action='store_true', default=False, help='Verbose mode')
|
parser.add_argument('-v', '--verbose', action='store_true', default=False, help='Verbose mode')
|
||||||
parser.add_argument('files', metavar='FILE1 [FILE2 ...]', type=str, nargs='+', help='Files to read. Use \'-\' for STDIN"')
|
parser.add_argument('files', metavar='FILE1 [FILE2 ...]', type=str, nargs='+', help='Files to read. Use \'-\' for STDIN"')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
print(args.files)
|
|
||||||
bu.setVerbose(args.verbose)
|
bu.setVerbose(args.verbose)
|
||||||
bu.setDebug(args.debug)
|
bu.setDebug(args.debug)
|
||||||
|
|
||||||
@@ -110,7 +109,6 @@ async def mkReplayQ(queue : asyncio.Queue, files : list, title : str):
|
|||||||
bu.debug('Finished')
|
bu.debug('Finished')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
async def mkQueueItem(filename : str, title : str) -> list:
|
async def mkQueueItem(filename : str, title : str) -> list:
|
||||||
"""Make an item to replay queue"""
|
"""Make an item to replay queue"""
|
||||||
global REPLAY_N
|
global REPLAY_N
|
||||||
@@ -125,7 +123,6 @@ async def replayWorker(queue: asyncio.Queue, workerID: int, account_id: int, pri
|
|||||||
while True:
|
while True:
|
||||||
item = await queue.get()
|
item = await queue.get()
|
||||||
filename = item[0]
|
filename = item[0]
|
||||||
# debug(filename)
|
|
||||||
N = item[1]
|
N = item[1]
|
||||||
title = item[2]
|
title = item[2]
|
||||||
replay_json_fn = filename + '.json'
|
replay_json_fn = filename + '.json'
|
||||||
|
|||||||
Reference in new issue
Block a user