1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-13 07:47:14 +03:00

Move companion.py category_map into data.py

This commit is contained in:
Athanasius 2021-04-03 10:24:13 +01:00
parent 5d289454a9
commit 5db62e48a3
3 changed files with 14 additions and 12 deletions

View File

@ -11,6 +11,7 @@ from os.path import isfile
from traceback import print_exc
import companion
import data
import outfitting
import util_ships
@ -54,13 +55,13 @@ def addcommodities(data):
new = {
'id' : commodity['id'],
'symbol' : commodity['name'],
'category' : companion.category_map.get(commodity['categoryname']) or commodity['categoryname'],
'category' : data.companion_category_map.get(commodity['categoryname']) or commodity['categoryname'],
'name' : commodity.get('locName') or 'Limpets',
}
old = commodities.get(key)
if old and companion.category_map.get(commodity['categoryname'], True):
if old and data.companion_category_map.get(commodity['categoryname'], True):
if new['symbol'] != old['symbol'] or new['name'] != old['name']:
raise ValueError('{}: {!r} != {!r}'.format(key, new, old))

View File

@ -27,6 +27,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Union, cast
import requests
from config import appname, appversion, config
from data import companion_category_map as category_map
from EDMCLogging import get_main_logger
from monitor import monitor
from protocol import protocolhandler
@ -64,16 +65,6 @@ URL_QUERY = '/profile'
URL_MARKET = '/market'
URL_SHIPYARD = '/shipyard'
# Map values reported by the Companion interface to names displayed in-game
# May be imported by plugins
category_map = {
'Narcotics': 'Legal Drugs',
'Slaves': 'Slavery',
'Waste ': 'Waste',
'NonMarketable': False, # Don't appear in the in-game market so don't report
}
commodity_map: Dict = {}

10
data.py
View File

@ -5,9 +5,19 @@ For easy reference any variable should be prefixed with the name of the file it
was either in originally, or where the primary code utilising it is.
"""
# Map numeric 'demand/supply brackets' to the names as shown in-game.
commodity_bracketmap = {
0: '',
1: 'Low',
2: 'Med',
3: 'High',
}
# Map values reported by the Companion interface to names displayed in-game.
# May be imported by plugins.
companion_category_map = {
'Narcotics': 'Legal Drugs',
'Slaves': 'Slavery',
'Waste ': 'Waste',
'NonMarketable': False, # Don't appear in the in-game market so don't report
}