mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-02 08:31:16 +03:00
[635] Remove Ordered Dict
This commit is contained in:
parent
5419e2e47f
commit
7cac00b2e8
@ -28,7 +28,7 @@ import urllib.parse
|
|||||||
import webbrowser
|
import webbrowser
|
||||||
from email.utils import parsedate
|
from email.utils import parsedate
|
||||||
from queue import Queue
|
from queue import Queue
|
||||||
from typing import TYPE_CHECKING, Any, Mapping, OrderedDict, TypeVar
|
from typing import TYPE_CHECKING, Any, Mapping, TypeVar
|
||||||
import requests
|
import requests
|
||||||
import config as conf_module
|
import config as conf_module
|
||||||
import killswitch
|
import killswitch
|
||||||
@ -1328,7 +1328,7 @@ def index_possibly_sparse_list(data: Mapping[str, V] | list[V], key: int) -> V:
|
|||||||
if isinstance(data, list):
|
if isinstance(data, list):
|
||||||
return data[key]
|
return data[key]
|
||||||
|
|
||||||
if isinstance(data, (dict, OrderedDict)):
|
if isinstance(data, (dict, dict)):
|
||||||
return data[str(key)]
|
return data[str(key)]
|
||||||
|
|
||||||
raise ValueError(f'Unexpected data type {type(data)}')
|
raise ValueError(f'Unexpected data type {type(data)}')
|
||||||
|
@ -16,7 +16,6 @@ FDevIDs/ version of the file, copy it over the local one.
|
|||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from collections import OrderedDict
|
|
||||||
|
|
||||||
import outfitting
|
import outfitting
|
||||||
from edmc_data import coriolis_ship_map, ship_name_map
|
from edmc_data import coriolis_ship_map, ship_name_map
|
||||||
@ -56,7 +55,7 @@ if __name__ == "__main__":
|
|||||||
for i, bulkhead in enumerate(bulkheads):
|
for i, bulkhead in enumerate(bulkheads):
|
||||||
modules['_'.join([reverse_ship_map[name], 'armour', bulkhead])] = {'mass': m['bulkheads'][i]['mass']}
|
modules['_'.join([reverse_ship_map[name], 'armour', bulkhead])] = {'mass': m['bulkheads'][i]['mass']}
|
||||||
|
|
||||||
ships = OrderedDict([(k, ships[k]) for k in sorted(ships)]) # sort for easier diffing
|
ships = {k: ships[k] for k in sorted(ships)}
|
||||||
with open("ships.json", "w") as ships_file:
|
with open("ships.json", "w") as ships_file:
|
||||||
json.dump(ships, ships_file, indent=4)
|
json.dump(ships, ships_file, indent=4)
|
||||||
|
|
||||||
@ -91,6 +90,6 @@ if __name__ == "__main__":
|
|||||||
add(modules, 'hpt_multicannon_fixed_small_advanced', {'mass': 2})
|
add(modules, 'hpt_multicannon_fixed_small_advanced', {'mass': 2})
|
||||||
add(modules, 'hpt_multicannon_fixed_medium_advanced', {'mass': 4})
|
add(modules, 'hpt_multicannon_fixed_medium_advanced', {'mass': 4})
|
||||||
|
|
||||||
modules = OrderedDict([(k, modules[k]) for k in sorted(modules)]) # sort for easier diffing
|
modules = {k: modules[k] for k in sorted(modules)}
|
||||||
with open("modules.json", "w") as modules_file:
|
with open("modules.json", "w") as modules_file:
|
||||||
json.dump(modules, modules_file, indent=4)
|
json.dump(modules, modules_file, indent=4)
|
||||||
|
16
edmc_data.py
16
edmc_data.py
@ -4,7 +4,6 @@ Static data.
|
|||||||
For easy reference any variable should be prefixed with the name of the file it
|
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.
|
was either in originally, or where the primary code utilising it is.
|
||||||
"""
|
"""
|
||||||
from collections import OrderedDict
|
|
||||||
|
|
||||||
# Map numeric 'demand/supply brackets' to the names as shown in-game.
|
# Map numeric 'demand/supply brackets' to the names as shown in-game.
|
||||||
commodity_bracketmap = {
|
commodity_bracketmap = {
|
||||||
@ -57,13 +56,14 @@ edshipyard_slot_map = {
|
|||||||
|
|
||||||
# Map API module names to in-game names
|
# Map API module names to in-game names
|
||||||
|
|
||||||
outfitting_armour_map = OrderedDict([
|
outfitting_armour_map = {
|
||||||
('grade1', 'Lightweight Alloy'),
|
'grade1': 'Lightweight Alloy',
|
||||||
('grade2', 'Reinforced Alloy'),
|
'grade2': 'Reinforced Alloy',
|
||||||
('grade3', 'Military Grade Composite'),
|
'grade3': 'Military Grade Composite',
|
||||||
('mirrored', 'Mirrored Surface Composite'),
|
'mirrored': 'Mirrored Surface Composite',
|
||||||
('reactive', 'Reactive Surface Composite'),
|
'reactive': 'Reactive Surface Composite',
|
||||||
])
|
}
|
||||||
|
|
||||||
|
|
||||||
outfitting_weapon_map = {
|
outfitting_weapon_map = {
|
||||||
'advancedtorppylon': 'Torpedo Pylon',
|
'advancedtorppylon': 'Torpedo Pylon',
|
||||||
|
7
l10n.py
7
l10n.py
@ -16,7 +16,6 @@ import numbers
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
from collections import OrderedDict
|
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from os import pardir, listdir, sep, makedirs
|
from os import pardir, listdir, sep, makedirs
|
||||||
from os.path import basename, dirname, isdir, isfile, join, abspath, exists
|
from os.path import basename, dirname, isdir, isfile, join, abspath, exists
|
||||||
@ -192,10 +191,10 @@ class _Translations:
|
|||||||
|
|
||||||
def available_names(self) -> dict[str | None, str]:
|
def available_names(self) -> dict[str | None, str]:
|
||||||
"""Available language names by code."""
|
"""Available language names by code."""
|
||||||
names: dict[str | None, str] = OrderedDict([
|
names: dict[str | None, str] = {
|
||||||
# LANG: The system default language choice in Settings > Appearance
|
# LANG: The system default language choice in Settings > Appearance
|
||||||
(None, _('Default')), # Appearance theme and language setting
|
None: _('Default'), # Appearance theme and language setting
|
||||||
])
|
}
|
||||||
names.update(sorted(
|
names.update(sorted(
|
||||||
[(lang, self.contents(lang).get(LANGUAGE_ID, lang)) for lang in self.available()] +
|
[(lang, self.contents(lang).get(LANGUAGE_ID, lang)) for lang in self.available()] +
|
||||||
[(_Translations.FALLBACK, _Translations.FALLBACK_NAME)],
|
[(_Translations.FALLBACK, _Translations.FALLBACK_NAME)],
|
||||||
|
12
monitor.py
12
monitor.py
@ -14,7 +14,7 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
from calendar import timegm
|
from calendar import timegm
|
||||||
from collections import OrderedDict, defaultdict
|
from collections import defaultdict
|
||||||
from os import SEEK_END, SEEK_SET, listdir
|
from os import SEEK_END, SEEK_SET, listdir
|
||||||
from os.path import basename, expanduser, getctime, isdir, join
|
from os.path import basename, expanduser, getctime, isdir, join
|
||||||
from time import gmtime, localtime, mktime, sleep, strftime, strptime, time
|
from time import gmtime, localtime, mktime, sleep, strftime, strptime, time
|
||||||
@ -567,7 +567,7 @@ class EDLogs(FileSystemEventHandler):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# Preserve property order because why not?
|
# Preserve property order because why not?
|
||||||
entry: MutableMapping[str, Any] = json.loads(line, object_pairs_hook=OrderedDict)
|
entry: MutableMapping[str, Any] = json.loads(line)
|
||||||
assert 'timestamp' in entry, "Timestamp does not exist in the entry"
|
assert 'timestamp' in entry, "Timestamp does not exist in the entry"
|
||||||
|
|
||||||
self.__navroute_retry()
|
self.__navroute_retry()
|
||||||
@ -1042,7 +1042,7 @@ class EDLogs(FileSystemEventHandler):
|
|||||||
rank[k] = (rank[k][0], min(v, 100))
|
rank[k] = (rank[k][0], min(v, 100))
|
||||||
|
|
||||||
elif event_type in ('reputation', 'statistics'):
|
elif event_type in ('reputation', 'statistics'):
|
||||||
payload = OrderedDict(entry)
|
payload = dict(entry)
|
||||||
payload.pop('event')
|
payload.pop('event')
|
||||||
payload.pop('timestamp')
|
payload.pop('timestamp')
|
||||||
# NB: We need the original casing for these keys
|
# NB: We need the original casing for these keys
|
||||||
@ -1073,7 +1073,7 @@ class EDLogs(FileSystemEventHandler):
|
|||||||
# From 3.3 full Cargo event (after the first one) is written to a separate file
|
# From 3.3 full Cargo event (after the first one) is written to a separate file
|
||||||
if 'Inventory' not in entry:
|
if 'Inventory' not in entry:
|
||||||
with open(join(self.currentdir, 'Cargo.json'), 'rb') as h: # type: ignore
|
with open(join(self.currentdir, 'Cargo.json'), 'rb') as h: # type: ignore
|
||||||
entry = json.load(h, object_pairs_hook=OrderedDict) # Preserve property order because why not?
|
entry = json.load(h) # Preserve property order because why not?
|
||||||
self.state['CargoJSON'] = entry
|
self.state['CargoJSON'] = entry
|
||||||
|
|
||||||
clean = self.coalesce_cargo(entry['Inventory'])
|
clean = self.coalesce_cargo(entry['Inventory'])
|
||||||
@ -1108,7 +1108,7 @@ class EDLogs(FileSystemEventHandler):
|
|||||||
attempts += 1
|
attempts += 1
|
||||||
try:
|
try:
|
||||||
with open(shiplocker_filename, 'rb') as h:
|
with open(shiplocker_filename, 'rb') as h:
|
||||||
entry = json.load(h, object_pairs_hook=OrderedDict)
|
entry = json.load(h)
|
||||||
self.state['ShipLockerJSON'] = entry
|
self.state['ShipLockerJSON'] = entry
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -2189,7 +2189,7 @@ class EDLogs(FileSystemEventHandler):
|
|||||||
'PowerDistributor', 'Radar', 'FuelTank'
|
'PowerDistributor', 'Radar', 'FuelTank'
|
||||||
)
|
)
|
||||||
|
|
||||||
d: MutableMapping[str, Any] = OrderedDict()
|
d: MutableMapping[str, Any] = {}
|
||||||
if timestamped:
|
if timestamped:
|
||||||
d['timestamp'] = strftime('%Y-%m-%dT%H:%M:%SZ', gmtime())
|
d['timestamp'] = strftime('%Y-%m-%dT%H:%M:%SZ', gmtime())
|
||||||
|
|
||||||
|
@ -8,8 +8,6 @@ See LICENSE file.
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from collections import OrderedDict
|
|
||||||
from typing import OrderedDict as OrderedDictT
|
|
||||||
from config import config
|
from config import config
|
||||||
from edmc_data import (
|
from edmc_data import (
|
||||||
outfitting_armour_map as armour_map,
|
outfitting_armour_map as armour_map,
|
||||||
@ -36,7 +34,7 @@ from EDMCLogging import get_main_logger
|
|||||||
logger = get_main_logger()
|
logger = get_main_logger()
|
||||||
|
|
||||||
# Module mass, FSD data etc
|
# Module mass, FSD data etc
|
||||||
moduledata: OrderedDictT = OrderedDict()
|
moduledata: dict = {}
|
||||||
|
|
||||||
|
|
||||||
def lookup(module, ship_map, entitled=False) -> dict | None: # noqa: C901, CCR001
|
def lookup(module, ship_map, entitled=False) -> dict | None: # noqa: C901, CCR001
|
||||||
|
102
plugins/eddn.py
102
plugins/eddn.py
@ -29,7 +29,6 @@ import re
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
import sys
|
import sys
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from collections import OrderedDict
|
|
||||||
from platform import system
|
from platform import system
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
@ -40,7 +39,6 @@ from typing import (
|
|||||||
Mapping,
|
Mapping,
|
||||||
MutableMapping,
|
MutableMapping,
|
||||||
)
|
)
|
||||||
from typing import OrderedDict as OrderedDictT
|
|
||||||
import requests
|
import requests
|
||||||
import companion
|
import companion
|
||||||
import edmc_data
|
import edmc_data
|
||||||
@ -98,13 +96,13 @@ class This:
|
|||||||
|
|
||||||
# Avoid duplicates
|
# Avoid duplicates
|
||||||
self.marketId: str | None = None
|
self.marketId: str | None = None
|
||||||
self.commodities: list[OrderedDictT[str, Any]] | None = None
|
self.commodities: list[dict[str, Any]] | None = None
|
||||||
self.outfitting: tuple[bool, list[str]] | None = None
|
self.outfitting: tuple[bool, list[str]] | None = None
|
||||||
self.shipyard: tuple[bool, list[Mapping[str, Any]]] | None = None
|
self.shipyard: tuple[bool, list[Mapping[str, Any]]] | None = None
|
||||||
self.fcmaterials_marketid: int = 0
|
self.fcmaterials_marketid: int = 0
|
||||||
self.fcmaterials: list[OrderedDictT[str, Any]] | None = None
|
self.fcmaterials: list[dict[str, Any]] | None = None
|
||||||
self.fcmaterials_capi_marketid: int = 0
|
self.fcmaterials_capi_marketid: int = 0
|
||||||
self.fcmaterials_capi: list[OrderedDictT[str, Any]] | None = None
|
self.fcmaterials_capi: list[dict[str, Any]] | None = None
|
||||||
|
|
||||||
# For the tkinter parent window, so we can call update_idletasks()
|
# For the tkinter parent window, so we can call update_idletasks()
|
||||||
self.parent: tk.Tk
|
self.parent: tk.Tk
|
||||||
@ -651,21 +649,21 @@ class EDDN:
|
|||||||
modules,
|
modules,
|
||||||
ships
|
ships
|
||||||
)
|
)
|
||||||
commodities: list[OrderedDictT[str, Any]] = []
|
commodities: list[dict[str, Any]] = []
|
||||||
for commodity in data['lastStarport'].get('commodities') or []:
|
for commodity in data['lastStarport'].get('commodities') or []:
|
||||||
# Check 'marketable' and 'not prohibited'
|
# Check 'marketable' and 'not prohibited'
|
||||||
if (category_map.get(commodity['categoryname'], True)
|
if (category_map.get(commodity['categoryname'], True)
|
||||||
and not commodity.get('legality')):
|
and not commodity.get('legality')):
|
||||||
commodities.append(OrderedDict([
|
commodities.append({
|
||||||
('name', commodity['name'].lower()),
|
'name': commodity['name'].lower(),
|
||||||
('meanPrice', int(commodity['meanPrice'])),
|
'meanPrice': int(commodity['meanPrice']),
|
||||||
('buyPrice', int(commodity['buyPrice'])),
|
'buyPrice': int(commodity['buyPrice']),
|
||||||
('stock', int(commodity['stock'])),
|
'stock': int(commodity['stock']),
|
||||||
('stockBracket', commodity['stockBracket']),
|
'stockBracket': commodity['stockBracket'],
|
||||||
('sellPrice', int(commodity['sellPrice'])),
|
'sellPrice': int(commodity['sellPrice']),
|
||||||
('demand', int(commodity['demand'])),
|
'demand': int(commodity['demand']),
|
||||||
('demandBracket', commodity['demandBracket']),
|
'demandBracket': commodity['demandBracket'],
|
||||||
]))
|
})
|
||||||
|
|
||||||
if commodity['statusFlags']:
|
if commodity['statusFlags']:
|
||||||
commodities[-1]['statusFlags'] = commodity['statusFlags']
|
commodities[-1]['statusFlags'] = commodity['statusFlags']
|
||||||
@ -679,15 +677,15 @@ class EDDN:
|
|||||||
# none and that really does need to be recorded over EDDN so that
|
# none and that really does need to be recorded over EDDN so that
|
||||||
# tools can update in a timely manner.
|
# tools can update in a timely manner.
|
||||||
if this.commodities != commodities:
|
if this.commodities != commodities:
|
||||||
message: OrderedDictT[str, Any] = OrderedDict([
|
message: dict[str, Any] = {
|
||||||
('timestamp', data['timestamp']),
|
'timestamp': data['timestamp'],
|
||||||
('systemName', data['lastSystem']['name']),
|
'systemName': data['lastSystem']['name'],
|
||||||
('stationName', data['lastStarport']['name']),
|
'stationName': data['lastStarport']['name'],
|
||||||
('marketId', data['lastStarport']['id']),
|
'marketId': data['lastStarport']['id'],
|
||||||
('commodities', commodities),
|
'commodities': commodities,
|
||||||
('horizons', horizons),
|
'horizons': horizons,
|
||||||
('odyssey', this.odyssey),
|
'odyssey': this.odyssey,
|
||||||
])
|
}
|
||||||
|
|
||||||
if 'economies' in data['lastStarport']:
|
if 'economies' in data['lastStarport']:
|
||||||
message['economies'] = sorted(
|
message['economies'] = sorted(
|
||||||
@ -802,7 +800,7 @@ class EDDN:
|
|||||||
if outfitting and this.outfitting != (horizons, outfitting):
|
if outfitting and this.outfitting != (horizons, outfitting):
|
||||||
self.send_message(data['commander']['name'], {
|
self.send_message(data['commander']['name'], {
|
||||||
'$schemaRef': f'https://eddn.edcd.io/schemas/outfitting/2{"/test" if is_beta else ""}',
|
'$schemaRef': f'https://eddn.edcd.io/schemas/outfitting/2{"/test" if is_beta else ""}',
|
||||||
'message': OrderedDict([
|
'message': {
|
||||||
('timestamp', data['timestamp']),
|
('timestamp', data['timestamp']),
|
||||||
('systemName', data['lastSystem']['name']),
|
('systemName', data['lastSystem']['name']),
|
||||||
('stationName', data['lastStarport']['name']),
|
('stationName', data['lastStarport']['name']),
|
||||||
@ -810,7 +808,7 @@ class EDDN:
|
|||||||
('horizons', horizons),
|
('horizons', horizons),
|
||||||
('modules', outfitting),
|
('modules', outfitting),
|
||||||
('odyssey', this.odyssey),
|
('odyssey', this.odyssey),
|
||||||
]),
|
},
|
||||||
'header': self.standard_header(
|
'header': self.standard_header(
|
||||||
game_version=self.capi_gameversion_from_host_endpoint(
|
game_version=self.capi_gameversion_from_host_endpoint(
|
||||||
data.source_host, companion.Session.FRONTIER_CAPI_PATH_SHIPYARD
|
data.source_host, companion.Session.FRONTIER_CAPI_PATH_SHIPYARD
|
||||||
@ -864,7 +862,7 @@ class EDDN:
|
|||||||
if shipyard and this.shipyard != (horizons, shipyard):
|
if shipyard and this.shipyard != (horizons, shipyard):
|
||||||
self.send_message(data['commander']['name'], {
|
self.send_message(data['commander']['name'], {
|
||||||
'$schemaRef': f'https://eddn.edcd.io/schemas/shipyard/2{"/test" if is_beta else ""}',
|
'$schemaRef': f'https://eddn.edcd.io/schemas/shipyard/2{"/test" if is_beta else ""}',
|
||||||
'message': OrderedDict([
|
'message': {
|
||||||
('timestamp', data['timestamp']),
|
('timestamp', data['timestamp']),
|
||||||
('systemName', data['lastSystem']['name']),
|
('systemName', data['lastSystem']['name']),
|
||||||
('stationName', data['lastStarport']['name']),
|
('stationName', data['lastStarport']['name']),
|
||||||
@ -872,7 +870,7 @@ class EDDN:
|
|||||||
('horizons', horizons),
|
('horizons', horizons),
|
||||||
('ships', shipyard),
|
('ships', shipyard),
|
||||||
('odyssey', this.odyssey),
|
('odyssey', this.odyssey),
|
||||||
]),
|
},
|
||||||
'header': self.standard_header(
|
'header': self.standard_header(
|
||||||
game_version=self.capi_gameversion_from_host_endpoint(
|
game_version=self.capi_gameversion_from_host_endpoint(
|
||||||
data.source_host, companion.Session.FRONTIER_CAPI_PATH_SHIPYARD
|
data.source_host, companion.Session.FRONTIER_CAPI_PATH_SHIPYARD
|
||||||
@ -898,16 +896,22 @@ class EDDN:
|
|||||||
:param entry: the journal entry containing the commodities data
|
:param entry: the journal entry containing the commodities data
|
||||||
"""
|
"""
|
||||||
items: list[Mapping[str, Any]] = entry.get('Items') or []
|
items: list[Mapping[str, Any]] = entry.get('Items') or []
|
||||||
commodities: list[OrderedDictT[str, Any]] = sorted((OrderedDict([
|
commodities: list[dict[str, Any]] = sorted(
|
||||||
('name', self.canonicalise(commodity['Name'])),
|
(
|
||||||
('meanPrice', commodity['MeanPrice']),
|
{
|
||||||
('buyPrice', commodity['BuyPrice']),
|
'name': self.canonicalise(commodity['Name']),
|
||||||
('stock', commodity['Stock']),
|
'meanPrice': commodity['MeanPrice'],
|
||||||
('stockBracket', commodity['StockBracket']),
|
'buyPrice': commodity['BuyPrice'],
|
||||||
('sellPrice', commodity['SellPrice']),
|
'stock': commodity['Stock'],
|
||||||
('demand', commodity['Demand']),
|
'stockBracket': commodity['StockBracket'],
|
||||||
('demandBracket', commodity['DemandBracket']),
|
'sellPrice': commodity['SellPrice'],
|
||||||
]) for commodity in items), key=lambda c: c['name'])
|
'demand': commodity['Demand'],
|
||||||
|
'demandBracket': commodity['DemandBracket'],
|
||||||
|
}
|
||||||
|
for commodity in items
|
||||||
|
),
|
||||||
|
key=lambda c: c['name']
|
||||||
|
)
|
||||||
|
|
||||||
# This used to have a check `commodities and ` at the start so as to
|
# This used to have a check `commodities and ` at the start so as to
|
||||||
# not send an empty commodities list, as the EDDN Schema doesn't allow
|
# not send an empty commodities list, as the EDDN Schema doesn't allow
|
||||||
@ -918,7 +922,7 @@ class EDDN:
|
|||||||
if this.commodities != commodities:
|
if this.commodities != commodities:
|
||||||
self.send_message(cmdr, {
|
self.send_message(cmdr, {
|
||||||
'$schemaRef': f'https://eddn.edcd.io/schemas/commodity/3{"/test" if is_beta else ""}',
|
'$schemaRef': f'https://eddn.edcd.io/schemas/commodity/3{"/test" if is_beta else ""}',
|
||||||
'message': OrderedDict([
|
'message': {
|
||||||
('timestamp', entry['timestamp']),
|
('timestamp', entry['timestamp']),
|
||||||
('systemName', entry['StarSystem']),
|
('systemName', entry['StarSystem']),
|
||||||
('stationName', entry['StationName']),
|
('stationName', entry['StationName']),
|
||||||
@ -926,7 +930,7 @@ class EDDN:
|
|||||||
('commodities', commodities),
|
('commodities', commodities),
|
||||||
('horizons', this.horizons),
|
('horizons', this.horizons),
|
||||||
('odyssey', this.odyssey),
|
('odyssey', this.odyssey),
|
||||||
]),
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
this.commodities = commodities
|
this.commodities = commodities
|
||||||
@ -957,7 +961,7 @@ class EDDN:
|
|||||||
if outfitting and this.outfitting != (horizons, outfitting):
|
if outfitting and this.outfitting != (horizons, outfitting):
|
||||||
self.send_message(cmdr, {
|
self.send_message(cmdr, {
|
||||||
'$schemaRef': f'https://eddn.edcd.io/schemas/outfitting/2{"/test" if is_beta else ""}',
|
'$schemaRef': f'https://eddn.edcd.io/schemas/outfitting/2{"/test" if is_beta else ""}',
|
||||||
'message': OrderedDict([
|
'message': {
|
||||||
('timestamp', entry['timestamp']),
|
('timestamp', entry['timestamp']),
|
||||||
('systemName', entry['StarSystem']),
|
('systemName', entry['StarSystem']),
|
||||||
('stationName', entry['StationName']),
|
('stationName', entry['StationName']),
|
||||||
@ -965,7 +969,7 @@ class EDDN:
|
|||||||
('horizons', horizons),
|
('horizons', horizons),
|
||||||
('modules', outfitting),
|
('modules', outfitting),
|
||||||
('odyssey', entry['odyssey'])
|
('odyssey', entry['odyssey'])
|
||||||
]),
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
this.outfitting = (horizons, outfitting)
|
this.outfitting = (horizons, outfitting)
|
||||||
@ -991,7 +995,7 @@ class EDDN:
|
|||||||
if shipyard and this.shipyard != (horizons, shipyard):
|
if shipyard and this.shipyard != (horizons, shipyard):
|
||||||
self.send_message(cmdr, {
|
self.send_message(cmdr, {
|
||||||
'$schemaRef': f'https://eddn.edcd.io/schemas/shipyard/2{"/test" if is_beta else ""}',
|
'$schemaRef': f'https://eddn.edcd.io/schemas/shipyard/2{"/test" if is_beta else ""}',
|
||||||
'message': OrderedDict([
|
'message': {
|
||||||
('timestamp', entry['timestamp']),
|
('timestamp', entry['timestamp']),
|
||||||
('systemName', entry['StarSystem']),
|
('systemName', entry['StarSystem']),
|
||||||
('stationName', entry['StationName']),
|
('stationName', entry['StationName']),
|
||||||
@ -999,7 +1003,7 @@ class EDDN:
|
|||||||
('horizons', horizons),
|
('horizons', horizons),
|
||||||
('ships', shipyard),
|
('ships', shipyard),
|
||||||
('odyssey', entry['odyssey'])
|
('odyssey', entry['odyssey'])
|
||||||
]),
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
# this.shipyard = (horizons, shipyard)
|
# this.shipyard = (horizons, shipyard)
|
||||||
@ -2182,14 +2186,14 @@ def plugin_stop() -> None:
|
|||||||
logger.debug('Done.')
|
logger.debug('Done.')
|
||||||
|
|
||||||
|
|
||||||
def filter_localised(d: Mapping[str, Any]) -> OrderedDictT[str, Any]:
|
def filter_localised(d: Mapping[str, Any]) -> dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
Recursively remove any dict keys with names ending `_Localised` from a dict.
|
Recursively remove any dict keys with names ending `_Localised` from a dict.
|
||||||
|
|
||||||
:param d: dict to filter keys of.
|
:param d: dict to filter keys of.
|
||||||
:return: The filtered dict.
|
:return: The filtered dict.
|
||||||
"""
|
"""
|
||||||
filtered: OrderedDictT[str, Any] = OrderedDict()
|
filtered: dict[str, Any] = {}
|
||||||
for k, v in d.items():
|
for k, v in d.items():
|
||||||
if k.endswith('_Localised'):
|
if k.endswith('_Localised'):
|
||||||
pass
|
pass
|
||||||
@ -2206,14 +2210,14 @@ def filter_localised(d: Mapping[str, Any]) -> OrderedDictT[str, Any]:
|
|||||||
return filtered
|
return filtered
|
||||||
|
|
||||||
|
|
||||||
def capi_filter_localised(d: Mapping[str, Any]) -> OrderedDictT[str, Any]:
|
def capi_filter_localised(d: Mapping[str, Any]) -> dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
Recursively remove any dict keys for known CAPI 'localised' names.
|
Recursively remove any dict keys for known CAPI 'localised' names.
|
||||||
|
|
||||||
:param d: dict to filter keys of.
|
:param d: dict to filter keys of.
|
||||||
:return: The filtered dict.
|
:return: The filtered dict.
|
||||||
"""
|
"""
|
||||||
filtered: OrderedDictT[str, Any] = OrderedDict()
|
filtered: dict[str, Any] = {}
|
||||||
for k, v in d.items():
|
for k, v in d.items():
|
||||||
if EDDN.CAPI_LOCALISATION_RE.search(k):
|
if EDDN.CAPI_LOCALISATION_RE.search(k):
|
||||||
pass
|
pass
|
||||||
|
163
plugins/inara.py
163
plugins/inara.py
@ -24,14 +24,13 @@ import json
|
|||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from collections import OrderedDict, defaultdict, deque
|
from collections import defaultdict, deque
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
from threading import Lock, Thread
|
from threading import Lock, Thread
|
||||||
from tkinter import ttk
|
from tkinter import ttk
|
||||||
from typing import TYPE_CHECKING, Any, Callable, Deque, Mapping, NamedTuple, Sequence, cast, Union
|
from typing import TYPE_CHECKING, Any, Callable, Deque, Mapping, NamedTuple, Sequence, cast, Union
|
||||||
from typing import OrderedDict as OrderedDictT
|
|
||||||
import requests
|
import requests
|
||||||
import edmc_data
|
import edmc_data
|
||||||
import killswitch
|
import killswitch
|
||||||
@ -102,12 +101,12 @@ class This:
|
|||||||
self.newsession: bool = True # starting a new session - wait for Cargo event
|
self.newsession: bool = True # starting a new session - wait for Cargo event
|
||||||
self.undocked: bool = False # just undocked
|
self.undocked: bool = False # just undocked
|
||||||
self.suppress_docked = False # Skip initial Docked event if started docked
|
self.suppress_docked = False # Skip initial Docked event if started docked
|
||||||
self.cargo: list[OrderedDictT[str, Any]] | None = None
|
self.cargo: list[dict[str, Any]] | None = None
|
||||||
self.materials: list[OrderedDictT[str, Any]] | None = None
|
self.materials: list[dict[str, Any]] | None = None
|
||||||
self.last_credits: int = 0 # Send credit update soon after Startup / new game
|
self.last_credits: int = 0 # Send credit update soon after Startup / new game
|
||||||
self.storedmodules: list[OrderedDictT[str, Any]] | None = None
|
self.storedmodules: list[dict[str, Any]] | None = None
|
||||||
self.loadout: OrderedDictT[str, Any] | None = None
|
self.loadout: dict[str, Any] | None = None
|
||||||
self.fleet: list[OrderedDictT[str, Any]] | None = None
|
self.fleet: list[dict[str, Any]] | None = None
|
||||||
self.shipswap: bool = False # just swapped ship
|
self.shipswap: bool = False # just swapped ship
|
||||||
self.on_foot = False
|
self.on_foot = False
|
||||||
|
|
||||||
@ -721,13 +720,13 @@ def journal_entry( # noqa: C901, CCR001
|
|||||||
this.suppress_docked = True
|
this.suppress_docked = True
|
||||||
|
|
||||||
# Send cargo and materials if changed
|
# Send cargo and materials if changed
|
||||||
cargo = [OrderedDict({'itemName': k, 'itemCount': state['Cargo'][k]}) for k in sorted(state['Cargo'])]
|
cargo = [{'itemName': k, 'itemCount': state['Cargo'][k]} for k in sorted(state['Cargo'])]
|
||||||
if this.cargo != cargo:
|
if this.cargo != cargo:
|
||||||
new_add_event('setCommanderInventoryCargo', entry['timestamp'], cargo)
|
new_add_event('setCommanderInventoryCargo', entry['timestamp'], cargo)
|
||||||
this.cargo = cargo
|
this.cargo = cargo
|
||||||
|
|
||||||
materials = [
|
materials = [
|
||||||
OrderedDict([('itemName', k), ('itemCount', state[category][k])])
|
{'itemName': k, 'itemCount': state[category][k]}
|
||||||
for category in ('Raw', 'Manufactured', 'Encoded')
|
for category in ('Raw', 'Manufactured', 'Encoded')
|
||||||
for k in sorted(state[category])
|
for k in sorted(state[category])
|
||||||
]
|
]
|
||||||
@ -823,8 +822,9 @@ def journal_entry( # noqa: C901, CCR001
|
|||||||
|
|
||||||
# Fleet
|
# Fleet
|
||||||
if event_name == 'StoredShips':
|
if event_name == 'StoredShips':
|
||||||
fleet: list[OrderedDictT[str, Any]] = sorted(
|
fleet = sorted(
|
||||||
[OrderedDict({
|
[
|
||||||
|
{
|
||||||
'shipType': x['ShipType'],
|
'shipType': x['ShipType'],
|
||||||
'shipGameID': x['ShipID'],
|
'shipGameID': x['ShipID'],
|
||||||
'shipName': x.get('Name'),
|
'shipName': x.get('Name'),
|
||||||
@ -832,15 +832,20 @@ def journal_entry( # noqa: C901, CCR001
|
|||||||
'starsystemName': entry['StarSystem'],
|
'starsystemName': entry['StarSystem'],
|
||||||
'stationName': entry['StationName'],
|
'stationName': entry['StationName'],
|
||||||
'marketID': entry['MarketID'],
|
'marketID': entry['MarketID'],
|
||||||
}) for x in entry['ShipsHere']] +
|
}
|
||||||
[OrderedDict({
|
for x in entry['ShipsHere']
|
||||||
|
] +
|
||||||
|
[
|
||||||
|
{
|
||||||
'shipType': x['ShipType'],
|
'shipType': x['ShipType'],
|
||||||
'shipGameID': x['ShipID'],
|
'shipGameID': x['ShipID'],
|
||||||
'shipName': x.get('Name'),
|
'shipName': x.get('Name'),
|
||||||
'isHot': x['Hot'],
|
'isHot': x['Hot'],
|
||||||
'starsystemName': x.get('StarSystem'), # Not present for ships in transit
|
'starsystemName': x.get('StarSystem'), # Not present for ships in transit
|
||||||
'marketID': x.get('ShipMarketID'), # "
|
'marketID': x.get('ShipMarketID'), # "
|
||||||
}) for x in entry['ShipsRemote']],
|
}
|
||||||
|
for x in entry['ShipsRemote']
|
||||||
|
],
|
||||||
key=itemgetter('shipGameID')
|
key=itemgetter('shipGameID')
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -851,7 +856,6 @@ def journal_entry( # noqa: C901, CCR001
|
|||||||
# this.events = [x for x in this.events if x['eventName'] != 'setCommanderShip'] # Remove any unsent
|
# this.events = [x for x in this.events if x['eventName'] != 'setCommanderShip'] # Remove any unsent
|
||||||
for ship in this.fleet:
|
for ship in this.fleet:
|
||||||
new_add_event('setCommanderShip', entry['timestamp'], ship)
|
new_add_event('setCommanderShip', entry['timestamp'], ship)
|
||||||
|
|
||||||
# Loadout
|
# Loadout
|
||||||
if event_name == 'Loadout' and not this.newsession:
|
if event_name == 'Loadout' and not this.newsession:
|
||||||
loadout = make_loadout(state)
|
loadout = make_loadout(state)
|
||||||
@ -870,14 +874,14 @@ def journal_entry( # noqa: C901, CCR001
|
|||||||
# Stored modules
|
# Stored modules
|
||||||
if event_name == 'StoredModules':
|
if event_name == 'StoredModules':
|
||||||
items = {mod['StorageSlot']: mod for mod in entry['Items']} # Impose an order
|
items = {mod['StorageSlot']: mod for mod in entry['Items']} # Impose an order
|
||||||
modules: list[OrderedDictT[str, Any]] = []
|
modules: list[dict[str, Any]] = []
|
||||||
for slot in sorted(items):
|
for slot in sorted(items):
|
||||||
item = items[slot]
|
item = items[slot]
|
||||||
module: OrderedDictT[str, Any] = OrderedDict([
|
module: dict[str, Any] = {
|
||||||
('itemName', item['Name']),
|
'itemName': item['Name'],
|
||||||
('itemValue', item['BuyPrice']),
|
'itemValue': item['BuyPrice'],
|
||||||
('isHot', item['Hot']),
|
'isHot': item['Hot'],
|
||||||
])
|
}
|
||||||
|
|
||||||
# Location can be absent if in transit
|
# Location can be absent if in transit
|
||||||
if 'StarSystem' in item:
|
if 'StarSystem' in item:
|
||||||
@ -887,7 +891,7 @@ def journal_entry( # noqa: C901, CCR001
|
|||||||
module['marketID'] = item['MarketID']
|
module['marketID'] = item['MarketID']
|
||||||
|
|
||||||
if 'EngineerModifications' in item:
|
if 'EngineerModifications' in item:
|
||||||
module['engineering'] = OrderedDict([('blueprintName', item['EngineerModifications'])])
|
module['engineering'] = {'blueprintName': item['EngineerModifications']}
|
||||||
if 'Level' in item:
|
if 'Level' in item:
|
||||||
module['engineering']['blueprintLevel'] = item['Level']
|
module['engineering']['blueprintLevel'] = item['Level']
|
||||||
|
|
||||||
@ -907,15 +911,15 @@ def journal_entry( # noqa: C901, CCR001
|
|||||||
|
|
||||||
# Missions
|
# Missions
|
||||||
if event_name == 'MissionAccepted':
|
if event_name == 'MissionAccepted':
|
||||||
data: OrderedDictT[str, Any] = OrderedDict([
|
data: dict[str, Any] = {
|
||||||
('missionName', entry['Name']),
|
'missionName': entry['Name'],
|
||||||
('missionGameID', entry['MissionID']),
|
'missionGameID': entry['MissionID'],
|
||||||
('influenceGain', entry['Influence']),
|
'influenceGain': entry['Influence'],
|
||||||
('reputationGain', entry['Reputation']),
|
'reputationGain': entry['Reputation'],
|
||||||
('starsystemNameOrigin', system),
|
'starsystemNameOrigin': system,
|
||||||
('stationNameOrigin', station),
|
'stationNameOrigin': station,
|
||||||
('minorfactionNameOrigin', entry['Faction']),
|
'minorfactionNameOrigin': entry['Faction'],
|
||||||
])
|
}
|
||||||
|
|
||||||
# optional mission-specific properties
|
# optional mission-specific properties
|
||||||
for (iprop, prop) in (
|
for (iprop, prop) in (
|
||||||
@ -946,7 +950,7 @@ def journal_entry( # noqa: C901, CCR001
|
|||||||
for x in entry.get('PermitsAwarded', []):
|
for x in entry.get('PermitsAwarded', []):
|
||||||
new_add_event('addCommanderPermit', entry['timestamp'], {'starsystemName': x})
|
new_add_event('addCommanderPermit', entry['timestamp'], {'starsystemName': x})
|
||||||
|
|
||||||
data = OrderedDict([('missionGameID', entry['MissionID'])])
|
data = {'missionGameID': entry['MissionID']}
|
||||||
if 'Donation' in entry:
|
if 'Donation' in entry:
|
||||||
data['donationCredits'] = entry['Donation']
|
data['donationCredits'] = entry['Donation']
|
||||||
|
|
||||||
@ -966,7 +970,7 @@ def journal_entry( # noqa: C901, CCR001
|
|||||||
|
|
||||||
factioneffects = []
|
factioneffects = []
|
||||||
for faction in entry.get('FactionEffects', []):
|
for faction in entry.get('FactionEffects', []):
|
||||||
effect: OrderedDictT[str, Any] = OrderedDict([('minorfactionName', faction['Faction'])])
|
effect: dict[str, Any] = {'minorfactionName': faction['Faction']}
|
||||||
for influence in faction.get('Influence', []):
|
for influence in faction.get('Influence', []):
|
||||||
if 'Influence' in influence:
|
if 'Influence' in influence:
|
||||||
highest_gain = influence['Influence']
|
highest_gain = influence['Influence']
|
||||||
@ -990,7 +994,7 @@ def journal_entry( # noqa: C901, CCR001
|
|||||||
|
|
||||||
# Combat
|
# Combat
|
||||||
if event_name == 'Died':
|
if event_name == 'Died':
|
||||||
data = OrderedDict([('starsystemName', system)])
|
data = {'starsystemName': system}
|
||||||
if 'Killers' in entry:
|
if 'Killers' in entry:
|
||||||
data['wingOpponentNames'] = [x['Name'] for x in entry['Killers']]
|
data['wingOpponentNames'] = [x['Name'] for x in entry['Killers']]
|
||||||
|
|
||||||
@ -1000,10 +1004,11 @@ def journal_entry( # noqa: C901, CCR001
|
|||||||
new_add_event('addCommanderCombatDeath', entry['timestamp'], data)
|
new_add_event('addCommanderCombatDeath', entry['timestamp'], data)
|
||||||
|
|
||||||
elif event_name == 'Interdicted':
|
elif event_name == 'Interdicted':
|
||||||
data = OrderedDict([('starsystemName', system),
|
data = {
|
||||||
('isPlayer', entry['IsPlayer']),
|
'starsystemName': system,
|
||||||
('isSubmit', entry['Submitted']),
|
'isPlayer': entry['IsPlayer'],
|
||||||
])
|
'isSubmit': entry['Submitted']
|
||||||
|
}
|
||||||
|
|
||||||
if 'Interdictor' in entry:
|
if 'Interdictor' in entry:
|
||||||
data['opponentName'] = entry['Interdictor']
|
data['opponentName'] = entry['Interdictor']
|
||||||
@ -1022,11 +1027,11 @@ def journal_entry( # noqa: C901, CCR001
|
|||||||
new_add_event('addCommanderCombatInterdicted', entry['timestamp'], data)
|
new_add_event('addCommanderCombatInterdicted', entry['timestamp'], data)
|
||||||
|
|
||||||
elif event_name == 'Interdiction':
|
elif event_name == 'Interdiction':
|
||||||
data = OrderedDict([
|
data = {
|
||||||
('starsystemName', system),
|
'starsystemName': system,
|
||||||
('isPlayer', entry['IsPlayer']),
|
'isPlayer': entry['IsPlayer'],
|
||||||
('isSuccess', entry['Success']),
|
'isSuccess': entry['Success'],
|
||||||
])
|
}
|
||||||
|
|
||||||
if 'Interdicted' in entry:
|
if 'Interdicted' in entry:
|
||||||
data['opponentName'] = entry['Interdicted']
|
data['opponentName'] = entry['Interdicted']
|
||||||
@ -1256,16 +1261,16 @@ def journal_entry( # noqa: C901, CCR001
|
|||||||
# ))
|
# ))
|
||||||
|
|
||||||
for goal in entry['CurrentGoals']:
|
for goal in entry['CurrentGoals']:
|
||||||
data = OrderedDict([
|
data = {
|
||||||
('communitygoalGameID', goal['CGID']),
|
'communitygoalGameID': goal['CGID'],
|
||||||
('communitygoalName', goal['Title']),
|
'communitygoalName': goal['Title'],
|
||||||
('starsystemName', goal['SystemName']),
|
'starsystemName': goal['SystemName'],
|
||||||
('stationName', goal['MarketName']),
|
'stationName': goal['MarketName'],
|
||||||
('goalExpiry', goal['Expiry']),
|
'goalExpiry': goal['Expiry'],
|
||||||
('isCompleted', goal['IsComplete']),
|
'isCompleted': goal['IsComplete'],
|
||||||
('contributorsNum', goal['NumContributors']),
|
'contributorsNum': goal['NumContributors'],
|
||||||
('contributionsTotal', goal['CurrentTotal']),
|
'contributionsTotal': goal['CurrentTotal'],
|
||||||
])
|
}
|
||||||
|
|
||||||
if 'TierReached' in goal:
|
if 'TierReached' in goal:
|
||||||
data['tierReached'] = int(goal['TierReached'].split()[-1])
|
data['tierReached'] = int(goal['TierReached'].split()[-1])
|
||||||
@ -1279,11 +1284,11 @@ def journal_entry( # noqa: C901, CCR001
|
|||||||
|
|
||||||
new_add_event('setCommunityGoal', entry['timestamp'], data)
|
new_add_event('setCommunityGoal', entry['timestamp'], data)
|
||||||
|
|
||||||
data = OrderedDict([
|
data = {
|
||||||
('communitygoalGameID', goal['CGID']),
|
'communitygoalGameID': goal['CGID'],
|
||||||
('contribution', goal['PlayerContribution']),
|
'contribution': goal['PlayerContribution'],
|
||||||
('percentileBand', goal['PlayerPercentileBand']),
|
'percentileBand': goal['PlayerPercentileBand'],
|
||||||
])
|
}
|
||||||
|
|
||||||
if 'Bonus' in goal:
|
if 'Bonus' in goal:
|
||||||
data['percentileBandReward'] = goal['Bonus']
|
data['percentileBandReward'] = goal['Bonus']
|
||||||
@ -1380,7 +1385,7 @@ def cmdr_data(data: CAPIData, is_beta): # noqa: CCR001, reanalyze me later
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def make_loadout(state: dict[str, Any]) -> OrderedDictT[str, Any]: # noqa: CCR001
|
def make_loadout(state: dict[str, Any]) -> dict[str, Any]: # noqa: CCR001
|
||||||
"""
|
"""
|
||||||
Construct an inara loadout from an event.
|
Construct an inara loadout from an event.
|
||||||
|
|
||||||
@ -1389,13 +1394,13 @@ def make_loadout(state: dict[str, Any]) -> OrderedDictT[str, Any]: # noqa: CCR0
|
|||||||
"""
|
"""
|
||||||
modules = []
|
modules = []
|
||||||
for m in state['Modules'].values():
|
for m in state['Modules'].values():
|
||||||
module: OrderedDictT[str, Any] = OrderedDict([
|
module: dict[str, Any] = {
|
||||||
('slotName', m['Slot']),
|
'slotName': m['Slot'],
|
||||||
('itemName', m['Item']),
|
'itemName': m['Item'],
|
||||||
('itemHealth', m['Health']),
|
'itemHealth': m['Health'],
|
||||||
('isOn', m['On']),
|
'isOn': m['On'],
|
||||||
('itemPriority', m['Priority']),
|
'itemPriority': m['Priority'],
|
||||||
])
|
}
|
||||||
|
|
||||||
if 'AmmoInClip' in m:
|
if 'AmmoInClip' in m:
|
||||||
module['itemAmmoClip'] = m['AmmoInClip']
|
module['itemAmmoClip'] = m['AmmoInClip']
|
||||||
@ -1410,20 +1415,20 @@ def make_loadout(state: dict[str, Any]) -> OrderedDictT[str, Any]: # noqa: CCR0
|
|||||||
module['isHot'] = m['Hot']
|
module['isHot'] = m['Hot']
|
||||||
|
|
||||||
if 'Engineering' in m:
|
if 'Engineering' in m:
|
||||||
engineering: OrderedDictT[str, Any] = OrderedDict([
|
engineering: dict[str, Any] = {
|
||||||
('blueprintName', m['Engineering']['BlueprintName']),
|
'blueprintName': m['Engineering']['BlueprintName'],
|
||||||
('blueprintLevel', m['Engineering']['Level']),
|
'blueprintLevel': m['Engineering']['Level'],
|
||||||
('blueprintQuality', m['Engineering']['Quality']),
|
'blueprintQuality': m['Engineering']['Quality'],
|
||||||
])
|
}
|
||||||
|
|
||||||
if 'ExperimentalEffect' in m['Engineering']:
|
if 'ExperimentalEffect' in m['Engineering']:
|
||||||
engineering['experimentalEffect'] = m['Engineering']['ExperimentalEffect']
|
engineering['experimentalEffect'] = m['Engineering']['ExperimentalEffect']
|
||||||
|
|
||||||
engineering['modifiers'] = []
|
engineering['modifiers'] = []
|
||||||
for mod in m['Engineering']['Modifiers']:
|
for mod in m['Engineering']['Modifiers']:
|
||||||
modifier: OrderedDictT[str, Any] = OrderedDict([
|
modifier: dict[str, Any] = {
|
||||||
('name', mod['Label']),
|
'name': mod['Label'],
|
||||||
])
|
}
|
||||||
|
|
||||||
if 'OriginalValue' in mod:
|
if 'OriginalValue' in mod:
|
||||||
modifier['value'] = mod['Value']
|
modifier['value'] = mod['Value']
|
||||||
@ -1439,11 +1444,11 @@ def make_loadout(state: dict[str, Any]) -> OrderedDictT[str, Any]: # noqa: CCR0
|
|||||||
|
|
||||||
modules.append(module)
|
modules.append(module)
|
||||||
|
|
||||||
return OrderedDict([
|
return {
|
||||||
('shipType', state['ShipType']),
|
'shipType': state['ShipType'],
|
||||||
('shipGameID', state['ShipID']),
|
'shipGameID': state['ShipID'],
|
||||||
('shipLoadout', modules),
|
'shipLoadout': modules,
|
||||||
])
|
}
|
||||||
|
|
||||||
|
|
||||||
def new_add_event(
|
def new_add_event(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user