use native logging formatter

This commit is contained in:
nyyu 2018-06-04 13:31:01 +02:00
parent d623d07e13
commit d905c5da72

View file

@ -51,7 +51,7 @@ def makeItemSetFromList(list, label, key, data):
} }
def writeItemSet(id, pos, ver, dir, session): def writeItemSet(id, pos, ver, dir, session):
logging.info('Retrieving data for %s at %s' % (id, pos)) logging.info('Retrieving data for %s at %s', id, pos)
data = getChampData(id, pos, session) data = getChampData(id, pos, session)
item_set = { item_set = {
@ -71,7 +71,7 @@ def writeItemSet(id, pos, ver, dir, session):
item_set['blocks'].append(makeItemSetFromList(CONSUMABLES, "Consumables | Frequent: %s", 'mostGames', data)) item_set['blocks'].append(makeItemSetFromList(CONSUMABLES, "Consumables | Frequent: %s", 'mostGames', data))
item_set['blocks'].append(makeItemSetFromList(TRINKETS, "Trinkets | Wins: %s", 'highestWinPercent', data)) item_set['blocks'].append(makeItemSetFromList(TRINKETS, "Trinkets | Wins: %s", 'highestWinPercent', data))
logging.info('Writing item set for %s at %s' % (id, pos)) logging.info('Writing item set for %s at %s', id, pos)
with open(dir.joinpath('CGG_%s_%s.json' % (id, pos)), 'w', newline='\n') as out: with open(dir.joinpath('CGG_%s_%s.json' % (id, pos)), 'w', newline='\n') as out:
json.dump(item_set, out, indent=4) json.dump(item_set, out, indent=4)
@ -87,13 +87,13 @@ def main():
data = session.get('http://ddragon.leagueoflegends.com/cdn/%s/data/en_US/champion.json' % ver).json()['data'] data = session.get('http://ddragon.leagueoflegends.com/cdn/%s/data/en_US/champion.json' % ver).json()['data']
lol_champs = [data[i] for i in data] lol_champs = [data[i] for i in data]
logging.info('LoL version: %s' % ver) logging.info('LoL version: %s', ver)
logging.info('LoL numbers of champs: %d' % len(lol_champs)) logging.info('LoL numbers of champs: %d', len(lol_champs))
(champs, patch) = getChampsWithPositionsAndPatch(session) (champs, patch) = getChampsWithPositionsAndPatch(session)
logging.info('CGG version: %s' % patch) logging.info('CGG version: %s', patch)
logging.info('CGG numbers of champs: %d' % len(champs)) logging.info('CGG numbers of champs: %d', len(champs))
for champ in champs: for champ in champs:
for name, positions in champ.items(): for name, positions in champ.items():
@ -105,7 +105,7 @@ def main():
writeItemSet(c['id'], pos, patch, path, session) writeItemSet(c['id'], pos, patch, path, session)
sleep(random.uniform(.3, .4)) sleep(random.uniform(.3, .4))
else: else:
logging.error('%s not found in LoL champs' % name) logging.error('%s not found in LoL champs', name)
if __name__ == "__main__": if __name__ == "__main__":
main() main()