mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-17 17:42:20 +03:00
collate: docstring module and addcommodities()
This commit is contained in:
parent
7fc6b624ee
commit
155d0082b0
17
collate.py
17
collate.py
@ -1,7 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
"""Collate lists of seen commodities, modules and ships from dumps of the Companion API output."""
|
||||||
# Script for collating lists of seen commodities, modules and ships from dumps of the Companion API output
|
|
||||||
#
|
|
||||||
|
|
||||||
import csv
|
import csv
|
||||||
import json
|
import json
|
||||||
@ -22,7 +20,6 @@ def __make_backup(file_name: str, suffix: str = '.bak') -> None:
|
|||||||
:param file_name: The name of the file to make a backup of
|
:param file_name: The name of the file to make a backup of
|
||||||
:param suffix: The suffix to use for backup files (default '.bak')
|
:param suffix: The suffix to use for backup files (default '.bak')
|
||||||
"""
|
"""
|
||||||
|
|
||||||
backup_name = file_name + suffix
|
backup_name = file_name + suffix
|
||||||
|
|
||||||
if isfile(backup_name):
|
if isfile(backup_name):
|
||||||
@ -31,9 +28,13 @@ def __make_backup(file_name: str, suffix: str = '.bak') -> None:
|
|||||||
os.rename(file_name, backup_name)
|
os.rename(file_name, backup_name)
|
||||||
|
|
||||||
|
|
||||||
# keep a summary of commodities found using in-game names
|
def addcommodities(data) -> None: # noqa: CCR001
|
||||||
# Assumes that the commodity data has already been 'fixed up'
|
"""
|
||||||
def addcommodities(data):
|
Keep a summary of commodities found using in-game names.
|
||||||
|
|
||||||
|
Assumes that the commodity data has already been 'fixed up'
|
||||||
|
:param data: - Fixed up commodity data.
|
||||||
|
"""
|
||||||
if not data['lastStarport'].get('commodities'):
|
if not data['lastStarport'].get('commodities'):
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -104,7 +105,7 @@ def addmodules(data):
|
|||||||
# sanity check
|
# sanity check
|
||||||
key = int(key)
|
key = int(key)
|
||||||
if key != module.get('id'):
|
if key != module.get('id'):
|
||||||
raise ValueError(f'id: {key} != {module['id']}')
|
raise ValueError(f'id: {key} != {module["id"]}')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
new = outfitting.lookup(module, ship_name_map, True)
|
new = outfitting.lookup(module, ship_name_map, True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user