From b4865cd10f2dabf003ee4208fe58f3686856f74f Mon Sep 17 00:00:00 2001 From: Rustam SecondFry Gubaydullin Date: Mon, 18 Dec 2023 12:30:37 +0300 Subject: [PATCH] Add ability to rename systems apart from SDE --- src/database/renames.csv | 6 ++++++ src/shortcircuit/app.py | 4 ++++ src/shortcircuit/model/evedb.py | 8 ++++++++ src/shortcircuit/model/test_evedb.py | 5 +++++ src/shortcircuit/model/test_solarmap.py | 14 +++++--------- 5 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 src/database/renames.csv diff --git a/src/database/renames.csv b/src/database/renames.csv new file mode 100644 index 0000000..817bbe1 --- /dev/null +++ b/src/database/renames.csv @@ -0,0 +1,6 @@ +solarSystemID,name +31000001,J055520 [Sentinel] +31000002,J110145 [Barbican] +31000003,J164710 [Vidette] +31000004,J200727 [Conflux] +31000006,J174618 [Redoubt] diff --git a/src/shortcircuit/app.py b/src/shortcircuit/app.py index da41a55..b65bf58 100644 --- a/src/shortcircuit/app.py +++ b/src/shortcircuit/app.py @@ -196,6 +196,7 @@ def additional_gui_setup(self): # Auto-completion system_list = self.nav.eve_db.system_name_list() + system_list.sort(key=str.lower) for line_edit_field in [ self.lineEdit_source, self.lineEdit_destination, @@ -204,6 +205,9 @@ def additional_gui_setup(self): ]: completer = QtWidgets.QCompleter(system_list, self) completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) + completer.setModelSorting( + QtWidgets.QCompleter.CaseInsensitivelySortedModel + ) line_edit_field.setCompleter(completer) # Signals diff --git a/src/shortcircuit/model/evedb.py b/src/shortcircuit/model/evedb.py index f3731d9..55d8684 100644 --- a/src/shortcircuit/model/evedb.py +++ b/src/shortcircuit/model/evedb.py @@ -355,6 +355,7 @@ class EveDb(metaclass=Singleton): def __init__(self): filename_statics = 'statics.csv' + filaname_renames = 'renames.csv' # NOTE(secondfry): thank you, Steve Ronuken. # @see https://www.fuzzwork.co.uk/dump/ @@ -363,6 +364,7 @@ def __init__(self): self._init_gates(get_csv_reader(filename_gates)) self._init_system_descriptions(get_csv_reader(filename_descriptions)) + self._init_renames(get_csv_reader(filaname_renames)) self.wh_codes: Dict[str, WormholeSize] = { rows[0]: WormholeSize(int(rows[1])) @@ -396,6 +398,12 @@ def _init_system_descriptions(self, reader): 'security': system.security } + def _init_renames(self, reader): + for row in reader: + id = int(row[0]) + name = row[1] + self.system_desc[id]['name'] = name + def get_whsize_by_code(self, code: str) -> WormholeSize: return self.wh_codes.get(code.upper(), WormholeSize.UNKNOWN) diff --git a/src/shortcircuit/model/test_evedb.py b/src/shortcircuit/model/test_evedb.py index 4facdf8..61c7421 100644 --- a/src/shortcircuit/model/test_evedb.py +++ b/src/shortcircuit/model/test_evedb.py @@ -14,3 +14,8 @@ def test_jita(): def test_tama(): eve_db = EveDb() assert eve_db.name2id("Tama") == 30002813 + + +def test_sentinel(): + eve_db = EveDb() + assert eve_db.name2id("J055520 [Sentinel]") == 31000001 diff --git a/src/shortcircuit/model/test_solarmap.py b/src/shortcircuit/model/test_solarmap.py index 1acc824..4a32696 100644 --- a/src/shortcircuit/model/test_solarmap.py +++ b/src/shortcircuit/model/test_solarmap.py @@ -82,7 +82,7 @@ def test_dodixie_jita_but_avoid_hs(): map = SolarMap(eve_db) path = map.shortest_path( eve_db.name2id("Dodixie"), - eve_db.name2id("Ikuchi"), + eve_db.name2id("Sujarento"), { "avoidance_list": [], "security_prio": { @@ -102,14 +102,10 @@ def test_dodixie_jita_but_avoid_hs(): 'Villore', 'Old Man Star', 'Heydieles', - 'Abune', - 'Oinasiken', - 'Nisuwa', - 'Kedama', - 'Tama', - 'Nourvukaiken', - 'Tunttaras', - 'Ikuchi', + 'Fliet', + 'Deven', + 'Nagamanen', + 'Sujarento', ]