From 3290cd63991be85aaee632929b36cd947aca3071 Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Sun, 9 Jun 2024 19:15:46 -0400 Subject: [PATCH 01/22] [2256] Allow Variable Num of Variables --- EDMarketConnector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index cd76ccc0..1b138dd8 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -454,7 +454,7 @@ class AppWindow: if sys.platform == 'win32': from simplesystray import SysTrayIcon - def open_window(systray: 'SysTrayIcon') -> None: + def open_window(systray: 'SysTrayIcon', *args) -> None: self.w.deiconify() menu_options = (("Open", None, open_window),) From d4b7173cf4a36a90d3fa3c1092b13fc3edc2c85f Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Sun, 9 Jun 2024 20:50:30 -0400 Subject: [PATCH 02/22] [525] Update Reddit and HTML Changelog --- .gitignore | 3 +- requirements-dev.txt | 2 +- scripts/build_changelog.py | 107 +++++++++++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 scripts/build_changelog.py diff --git a/.gitignore b/.gitignore index 778820c6..1df2f666 100644 --- a/.gitignore +++ b/.gitignore @@ -9,8 +9,9 @@ build dist.win32/ dist.* -# Ignore generated ChangeLog.html file +# Ignore generated ChangeLog files ChangeLog.html +/scripts/script_output # Ignore files dump diff --git a/requirements-dev.txt b/requirements-dev.txt index 7c8e1ef5..05c5ad29 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -31,7 +31,7 @@ autopep8==2.2.0 pre-commit==3.7.1 # HTML changelogs -grip==4.6.2 +mistune==3.0.2 # Packaging # We only need py2exe on windows. diff --git a/scripts/build_changelog.py b/scripts/build_changelog.py new file mode 100644 index 00000000..ce266fd7 --- /dev/null +++ b/scripts/build_changelog.py @@ -0,0 +1,107 @@ +#!/usr/bin/env python3 +# flake8: noqa +""" +build_changelog.py - Read the latest changelog file and format for the Forums and Reddit. + +Copyright (c) EDCD, All Rights Reserved +Licensed under the GNU General Public License. +See LICENSE file. +""" +import pathlib +import re +from os import chdir +import mistune + + +def get_changelog() -> str: + """Pull the last full changelog details in MD.""" + with open("../CHANGELOG.md", encoding="utf-8") as changelog_file: + content = changelog_file.read() + changelog_list: list = content.split("---", maxsplit=2) + changelog = changelog_list[2] + changelog_list = changelog.split("===", maxsplit=2) + changelog_list[0] = changelog_list[0].rstrip() + changelog_list[0] = changelog_list[0].lstrip() + changelog_list[0] += "\n===" + changelog_list[1] = changelog_list[1].rstrip() + changelog_list[1] = "\n".join(changelog_list[1].split("\n")[:-2]) + changelog = changelog_list[0] + changelog_list[1] + changelog = changelog.rstrip() + return changelog + + +def build_html(md_changelog) -> None: + html_out = mistune.html(md_changelog) + html_out = re.sub("h1", "h2", html_out) + html_out += "\n
" + with open("script_output/html_changelog.txt", "w", encoding="utf-8") as html_file: + html_file.write(html_out) + + +def build_reddit( + md_changelog: str, vt_signed: str, vt_unsigned: str, version: str, gh_link: str +) -> None: + reddit_start = """# What Is Elite Dangerous Market Connector? + +Elite Dangerous Market Connector ("EDMC") is a third-party application for use with Frontier Developments' game "Elite Dangerous". Its purpose is to facilitate supplying certain game data to, and in some cases retrieving it from, a number of websites and other tools. + +To achieve this it utilizes the Journal Files written by the game when played on a PC. It also makes use of Frontier's Companion API ("Frontier's CAPI"), accessible once you've authorized this application. + +EDMC has a plugin system that many other developers have made use of to extend its functionality. + +Find out more on the [EDMC Wiki](https://github.com/EDCD/EDMarketConnector/wiki). + +~~----------------------------------------------------~~ + +You can also view the Elite: Dangerous Forum thread [HERE](https://forums.frontier.co.uk/threads/elite-dangerous-market-connector-edmc.618708/). + +~~----------------------------------------------------~~ + +**As has become routine now, various anti-virus software are reporting a false positive on our installer and/or files it contains. We've pre-emptively uploaded the installer to** [VirusTotal]( +""" + reddit_mid_1 = """) **if you want to check what it's saying. Please see our** [Troubleshooting/AV-false-positives FAQ](https://github.com/EDCD/EDMarketConnector/wiki/Troubleshooting#installer-and-or-executables-flagged-as-malicious-viruses) **for further information.** + +[Unsigned Installer](""" + + reddit_mid_2 = """) if you don't want to use the code-signed option. + +~~----------------------------------------------------~~ +""" + versionsearch = f"Release {version}" + updated = f"# [Release {version}]({gh_link})" + md_changelog = re.sub("===\n", "", md_changelog) + md_changelog = re.sub(versionsearch, updated, md_changelog) + reddit_end = f""" + +**Linux** + +If you're running on Linux, try the [Flatpak](https://flathub.org/apps/io.edcd.EDMarketConnector) build of EDMC! (Update to {version} coming soon.)""" + + reddit_out = ( + reddit_start + + vt_signed + + reddit_mid_1 + + vt_unsigned + + reddit_mid_2 + + md_changelog + + reddit_end + ) + with open( + "script_output/reddit_changelog.txt", "w", encoding="utf-8" + ) as reddit_file: + reddit_file.write(reddit_out) + + +def main() -> None: + vt_signed = input("Please enter the VirusTotal URL for the Signed Installer: ") + vt_unsigned = input("Please enter the VirusTotal URL for the Unsigned Installer: ") + version = input("Please enter the version of EDMC: ") + gh_link = input(f"Please enter the GitHub link for {version}: ") + md_changelog = get_changelog() + build_reddit(md_changelog, vt_signed, vt_unsigned, version, gh_link) + build_html(md_changelog) + + +if __name__ == "__main__": + chdir(pathlib.Path(__file__).parent) + main() From 340c9818fcecc60af66f14f405342d50f79c8cbf Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Sun, 9 Jun 2024 21:22:24 -0400 Subject: [PATCH 03/22] [525] Add FDEV Forum Post --- scripts/build_changelog.py | 65 ++++++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 7 deletions(-) diff --git a/scripts/build_changelog.py b/scripts/build_changelog.py index ce266fd7..c4772a83 100644 --- a/scripts/build_changelog.py +++ b/scripts/build_changelog.py @@ -13,7 +13,7 @@ from os import chdir import mistune -def get_changelog() -> str: +def get_changelog() -> tuple[str, str]: """Pull the last full changelog details in MD.""" with open("../CHANGELOG.md", encoding="utf-8") as changelog_file: content = changelog_file.read() @@ -27,15 +27,65 @@ def get_changelog() -> str: changelog_list[1] = "\n".join(changelog_list[1].split("\n")[:-2]) changelog = changelog_list[0] + changelog_list[1] changelog = changelog.rstrip() - return changelog + version = changelog.split("\n")[0] + version = version.split(" ")[1] + return changelog, version -def build_html(md_changelog) -> None: +def build_html(md_changelog) -> str: html_out = mistune.html(md_changelog) html_out = re.sub("h1", "h2", html_out) html_out += "\n
" with open("script_output/html_changelog.txt", "w", encoding="utf-8") as html_file: html_file.write(html_out) + return html_out + + +def build_fdev( + vt_signed: str, + vt_unsigned: str, + version: str, + gh_link: str, + html: str, +) -> None: + fdev_out = ( + "[HEADING=2][URL='" + + gh_link + + "'][SIZE=7]Release " + + version + + "[/SIZE][/URL][/HEADING]\n[URL='" + + vt_signed + ) + fdev_out += ( + "']Pre-emptive upload to VirusTotal[/URL]. ([URL='" + + vt_unsigned + + "']Unsigned Installer[/URL])\n\n" + ) + + if version.startswith("Pre-Release") or version.startswith("Beta"): + fdev_out += f'This is a release candidate for {version}. It has been pushed to the "Beta" track for updates!' + fdev_out += ( + '\n\nFor more information on the "Beta" update track, please read ' + "[URL='https://github.com/EDCD/EDMarketConnector/wiki/Participating-in-Open-Betas-of-EDMC']" + "This Wiki Article[/URL]. Questions and comments are welcome!\n\n" + ) + changelog_trim = html.split("\n", maxsplit=1) + md_log = changelog_trim[1] + md_log = re.sub("

", "", md_log) + md_log = re.sub("

", "", md_log) + md_log = re.sub("", "\n[HEADING=3]", md_log) + md_log = re.sub("", "[/HEADING]", md_log) + md_log = re.sub("
    ", "[LIST]", md_log) + md_log = re.sub("
  • ", "[*]", md_log) + md_log = re.sub("
  • ", "", md_log) + md_log = re.sub("", "[ICODE]", md_log) + md_log = re.sub("", "[/ICODE]", md_log) + md_log = re.sub("
\n", "[/LIST]", md_log) + fdev_out += md_log + + with open("script_output/fdev_changelog.txt", "w", encoding="utf-8") as fdev_file: + fdev_file.write(fdev_out) + return def build_reddit( @@ -93,13 +143,14 @@ If you're running on Linux, try the [Flatpak](https://flathub.org/apps/io.edcd.E def main() -> None: + md_changelog, version = get_changelog() + print(f"Detected version {version} in the changelog. Continuing...") + gh_link = input(f"Please enter the GitHub link for {version}: ") vt_signed = input("Please enter the VirusTotal URL for the Signed Installer: ") vt_unsigned = input("Please enter the VirusTotal URL for the Unsigned Installer: ") - version = input("Please enter the version of EDMC: ") - gh_link = input(f"Please enter the GitHub link for {version}: ") - md_changelog = get_changelog() build_reddit(md_changelog, vt_signed, vt_unsigned, version, gh_link) - build_html(md_changelog) + html = build_html(md_changelog) + build_fdev(vt_signed, vt_unsigned, version, gh_link, html) if __name__ == "__main__": From 33f8e9c83707431ca5e4cd1f16120d0220ad1d1f Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Sun, 9 Jun 2024 21:51:56 -0400 Subject: [PATCH 04/22] [525] Cleanup Script --- scripts/build_changelog.py | 125 ++++++++++++++++++++----------------- 1 file changed, 66 insertions(+), 59 deletions(-) diff --git a/scripts/build_changelog.py b/scripts/build_changelog.py index c4772a83..f0c01994 100644 --- a/scripts/build_changelog.py +++ b/scripts/build_changelog.py @@ -7,6 +7,7 @@ Copyright (c) EDCD, All Rights Reserved Licensed under the GNU General Public License. See LICENSE file. """ + import pathlib import re from os import chdir @@ -15,82 +16,87 @@ import mistune def get_changelog() -> tuple[str, str]: """Pull the last full changelog details in MD.""" - with open("../CHANGELOG.md", encoding="utf-8") as changelog_file: - content = changelog_file.read() - changelog_list: list = content.split("---", maxsplit=2) - changelog = changelog_list[2] - changelog_list = changelog.split("===", maxsplit=2) - changelog_list[0] = changelog_list[0].rstrip() - changelog_list[0] = changelog_list[0].lstrip() - changelog_list[0] += "\n===" - changelog_list[1] = changelog_list[1].rstrip() - changelog_list[1] = "\n".join(changelog_list[1].split("\n")[:-2]) - changelog = changelog_list[0] + changelog_list[1] - changelog = changelog.rstrip() - version = changelog.split("\n")[0] - version = version.split(" ")[1] - return changelog, version + try: + with open("../CHANGELOG.md", encoding="utf-8") as changelog_file: + content = changelog_file.read() + except FileNotFoundError as exc: + raise FileNotFoundError("Changelog file not found.") from exc + + changelog_list = content.split("---", maxsplit=2) + if len(changelog_list) < 3: + raise ValueError("Changelog format is incorrect.") + + changelog = changelog_list[2].split("===", maxsplit=2) + if len(changelog) < 2: + raise ValueError("Changelog format is incorrect.") + + changelog[0] = changelog[0].strip() + changelog[1] = "\n".join(changelog[1].strip().split("\n")[:-2]) + version = changelog[0] + version = version.split(" ")[1] + changelog = changelog[1].strip() + + return changelog, version -def build_html(md_changelog) -> str: - html_out = mistune.html(md_changelog) - html_out = re.sub("h1", "h2", html_out) - html_out += "\n
" +def build_html(md_changelog: str, version: str) -> str: + """Convert markdown changelog to HTML.""" + html_out = f"

Release {version}

\n" + html_out += mistune.html(md_changelog) + html_out = re.sub(r"h1", "h2", html_out) + "\n
" + with open("script_output/html_changelog.txt", "w", encoding="utf-8") as html_file: html_file.write(html_out) + return html_out +def format_fdev(md_log: str) -> str: + """Format changelog for FDEV forums.""" + md_log = re.sub(r"

|

", "", md_log) + md_log = re.sub(r"", "\n[HEADING=3]", md_log) + md_log = re.sub(r"", "[/HEADING]", md_log) + md_log = re.sub(r"
    ", "[LIST]", md_log) + md_log = re.sub(r"
  • ", "[*]", md_log) + md_log = re.sub(r"
  • ", "", md_log) + md_log = re.sub(r"", "[ICODE]", md_log) + md_log = re.sub(r"", "[/ICODE]", md_log) + md_log = re.sub(r"
\n", "[/LIST]", md_log) + md_log = re.sub(r"
", "", md_log) + md_log = re.sub(r"Changes and Enhancements", "What's Changed", md_log) + return md_log + + def build_fdev( - vt_signed: str, - vt_unsigned: str, - version: str, - gh_link: str, - html: str, + vt_signed: str, vt_unsigned: str, version: str, gh_link: str, html: str ) -> None: + """Build changelog for FDEV forums.""" fdev_out = ( - "[HEADING=2][URL='" - + gh_link - + "'][SIZE=7]Release " - + version - + "[/SIZE][/URL][/HEADING]\n[URL='" - + vt_signed - ) - fdev_out += ( - "']Pre-emptive upload to VirusTotal[/URL]. ([URL='" - + vt_unsigned - + "']Unsigned Installer[/URL])\n\n" + f"[HEADING=2][URL='{gh_link}'][SIZE=7]Release {version}[/SIZE][/URL][/HEADING]\n" + f"[URL='{vt_signed}']Pre-emptive upload to VirusTotal[/URL]. " + f"([URL='{vt_unsigned}']Unsigned Installer[/URL])\n\n" ) - if version.startswith("Pre-Release") or version.startswith("Beta"): - fdev_out += f'This is a release candidate for {version}. It has been pushed to the "Beta" track for updates!' + if version.startswith(("Pre-Release", "Beta")): fdev_out += ( - '\n\nFor more information on the "Beta" update track, please read ' + f'This is a release candidate for {version}. It has been pushed to the "Beta" track for updates!\n\n' + 'For more information on the "Beta" update track, please read ' "[URL='https://github.com/EDCD/EDMarketConnector/wiki/Participating-in-Open-Betas-of-EDMC']" "This Wiki Article[/URL]. Questions and comments are welcome!\n\n" ) - changelog_trim = html.split("\n", maxsplit=1) - md_log = changelog_trim[1] - md_log = re.sub("

", "", md_log) - md_log = re.sub("

", "", md_log) - md_log = re.sub("", "\n[HEADING=3]", md_log) - md_log = re.sub("", "[/HEADING]", md_log) - md_log = re.sub("
    ", "[LIST]", md_log) - md_log = re.sub("
  • ", "[*]", md_log) - md_log = re.sub("
  • ", "", md_log) - md_log = re.sub("", "[ICODE]", md_log) - md_log = re.sub("", "[/ICODE]", md_log) - md_log = re.sub("
\n", "[/LIST]", md_log) + + md_log = html.split("\n", maxsplit=1)[1] + md_log = format_fdev(md_log) fdev_out += md_log with open("script_output/fdev_changelog.txt", "w", encoding="utf-8") as fdev_file: fdev_file.write(fdev_out) - return def build_reddit( md_changelog: str, vt_signed: str, vt_unsigned: str, version: str, gh_link: str ) -> None: + """Build changelog for Reddit.""" reddit_start = """# What Is Elite Dangerous Market Connector? Elite Dangerous Market Connector ("EDMC") is a third-party application for use with Frontier Developments' game "Elite Dangerous". Its purpose is to facilitate supplying certain game data to, and in some cases retrieving it from, a number of websites and other tools. @@ -107,9 +113,8 @@ You can also view the Elite: Dangerous Forum thread [HERE](https://forums.fronti ~~----------------------------------------------------~~ -**As has become routine now, various anti-virus software are reporting a false positive on our installer and/or files it contains. We've pre-emptively uploaded the installer to** [VirusTotal]( -""" - reddit_mid_1 = """) **if you want to check what it's saying. Please see our** [Troubleshooting/AV-false-positives FAQ](https://github.com/EDCD/EDMarketConnector/wiki/Troubleshooting#installer-and-or-executables-flagged-as-malicious-viruses) **for further information.** +**As has become routine now, various anti-virus software are reporting a false positive on our installer and/or files it contains. We've pre-emptively uploaded the installer to** [VirusTotal](""" + reddit_mid_1 = """) **if you want to check what it's saying. Please see our** [Troubleshooting/AV-false-positives FAQ](https://github.com/EDCD/EDMarketConnector/wiki/Troubleshooting#installer-and-or-executables-flagged-as-malicious-viruses) **for further information.** [Unsigned Installer](""" @@ -117,10 +122,9 @@ You can also view the Elite: Dangerous Forum thread [HERE](https://forums.fronti ~~----------------------------------------------------~~ """ - versionsearch = f"Release {version}" - updated = f"# [Release {version}]({gh_link})" - md_changelog = re.sub("===\n", "", md_changelog) - md_changelog = re.sub(versionsearch, updated, md_changelog) + updated = f"# [Release {version}]({gh_link})\n\n" + md_changelog = re.sub(r"===\n", "", md_changelog) + md_changelog = re.sub(f"Release {version}", updated, md_changelog) reddit_end = f""" **Linux** @@ -133,9 +137,11 @@ If you're running on Linux, try the [Flatpak](https://flathub.org/apps/io.edcd.E + reddit_mid_1 + vt_unsigned + reddit_mid_2 + + updated + md_changelog + reddit_end ) + with open( "script_output/reddit_changelog.txt", "w", encoding="utf-8" ) as reddit_file: @@ -143,13 +149,14 @@ If you're running on Linux, try the [Flatpak](https://flathub.org/apps/io.edcd.E def main() -> None: + """Run the Changelog Generator""" md_changelog, version = get_changelog() print(f"Detected version {version} in the changelog. Continuing...") gh_link = input(f"Please enter the GitHub link for {version}: ") vt_signed = input("Please enter the VirusTotal URL for the Signed Installer: ") vt_unsigned = input("Please enter the VirusTotal URL for the Unsigned Installer: ") build_reddit(md_changelog, vt_signed, vt_unsigned, version, gh_link) - html = build_html(md_changelog) + html = build_html(md_changelog, version) build_fdev(vt_signed, vt_unsigned, version, gh_link, html) From c60c0483b45149908c14300b1bb9860b2a55d062 Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Sat, 15 Jun 2024 22:13:34 -0400 Subject: [PATCH 05/22] [#2262] Initial SLEF Output --- coriolis-update-files.py | 3 +- inara.json | 267 +++++++++++++++++++++++++++++++++++++++ plugins/inara.py | 53 ++++++++ ships.json | 117 +++++++++++------ 4 files changed, 400 insertions(+), 40 deletions(-) create mode 100644 inara.json diff --git a/coriolis-update-files.py b/coriolis-update-files.py index f31a2e32..6dfcc0c9 100755 --- a/coriolis-update-files.py +++ b/coriolis-update-files.py @@ -51,7 +51,8 @@ if __name__ == "__main__": for m in list(data['Ships'].values()): name = coriolis_ship_map.get(m['properties']['name'], str(m['properties']['name'])) assert name in reverse_ship_map, name - ships[name] = {'hullMass': m['properties']['hullMass']} + ships[name] = {'hullMass': m['properties']['hullMass'], + 'reserveFuelCapacity': m['properties']['reserveFuelCapacity']} for i, bulkhead in enumerate(bulkheads): modules['_'.join([reverse_ship_map[name], 'armour', bulkhead])] = {'mass': m['bulkheads'][i]['mass']} diff --git a/inara.json b/inara.json new file mode 100644 index 00000000..1c5cba8a --- /dev/null +++ b/inara.json @@ -0,0 +1,267 @@ +{ + "header": { + "appName": "EDMarketConnector", + "appVersion": "5.11.1+85f5c328.DIRTY" + }, + "data": { + "FuelCapacity": { + "Main": 128, + "Reserve": 0.81 + }, + "Ship": "belugaliner", + "ShipName": "HSRV Guiding Light", + "ShipIdent": "NFC-23", + "HullValue": 69924158, + "ModulesValue": 96918434, + "Rebuy": 8342132, + "MaxJumpRange": 52.615143, + "UnladenMass": 1233.057983, + "CargoCapacity": 16, + "Modules": [ + { + "Slot": "TinyHardpoint1", + "Item": "hpt_heatsinklauncher_turret_tiny", + "ItemHealth": 1.0, + "On": true, + "Value": 3072 + }, + { + "Slot": "TinyHardpoint2", + "Item": "hpt_heatsinklauncher_turret_tiny", + "ItemHealth": 1.0, + "On": true, + "Value": 3413 + }, + { + "Slot": "TinyHardpoint3", + "Item": "hpt_heatsinklauncher_turret_tiny", + "ItemHealth": 1.0, + "On": true, + "Value": 3072 + }, + { + "Slot": "TinyHardpoint4", + "Item": "hpt_heatsinklauncher_turret_tiny", + "ItemHealth": 1.0, + "On": true, + "Value": 3072 + }, + { + "Slot": "PaintJob", + "Item": "paintjob_belugaliner_lrpo_azure", + "ItemHealth": 1.0, + "On": true, + "Priority": 1 + }, + { + "Slot": "Armour", + "Item": "belugaliner_armour_grade1", + "ItemHealth": 1.0, + "On": true, + "Priority": 1 + }, + { + "Slot": "PowerPlant", + "Item": "int_powerplant_size6_class5", + "ItemHealth": 1.0, + "On": true, + "Priority": 1, + "Value": 11382139 + }, + { + "Slot": "MainEngines", + "Item": "int_engine_size7_class2", + "ItemHealth": 1.0, + "On": true, + "Priority": 1, + "Value": 1666898 + }, + { + "Slot": "FrameShiftDrive", + "Item": "int_hyperdrive_size7_class5", + "ItemHealth": 1.0, + "On": true, + "Value": 45006196 + }, + { + "Slot": "LifeSupport", + "Item": "int_lifesupport_size8_class2", + "ItemHealth": 1.0, + "On": true, + "Value": 1530326 + }, + { + "Slot": "PowerDistributor", + "Item": "int_powerdistributor_size6_class5", + "ItemHealth": 1.0, + "On": true, + "Priority": 1, + "Value": 3049917 + }, + { + "Slot": "Radar", + "Item": "int_sensors_size5_class2", + "ItemHealth": 1.0, + "On": true, + "Priority": 1, + "Value": 69713 + }, + { + "Slot": "FuelTank", + "Item": "int_fueltank_size7_class3", + "ItemHealth": 1.0, + "On": true, + "Priority": 1, + "Value": 1562752 + }, + { + "Slot": "Decal1", + "Item": "decal_distantworlds2", + "ItemHealth": 1.0, + "On": true, + "Priority": 1 + }, + { + "Slot": "Decal2", + "Item": "decal_distantworlds2", + "ItemHealth": 1.0, + "On": true, + "Priority": 1 + }, + { + "Slot": "Decal3", + "Item": "decal_distantworlds2", + "ItemHealth": 1.0, + "On": true, + "Priority": 1 + }, + { + "Slot": "ShipName0", + "Item": "nameplate_practical01_black", + "ItemHealth": 1.0, + "On": true, + "Priority": 1 + }, + { + "Slot": "ShipName1", + "Item": "nameplate_practical01_black", + "ItemHealth": 1.0, + "On": true, + "Priority": 1 + }, + { + "Slot": "ShipID0", + "Item": "nameplate_shipid_singleline_black", + "ItemHealth": 1.0, + "On": true, + "Priority": 1 + }, + { + "Slot": "ShipID1", + "Item": "nameplate_shipid_singleline_black", + "ItemHealth": 1.0, + "On": true, + "Priority": 1 + }, + { + "Slot": "Slot01_Size6", + "Item": "int_fuelscoop_size6_class5", + "ItemHealth": 1.0, + "On": true, + "Value": 25240068 + }, + { + "Slot": "Slot02_Size6", + "Item": "int_repairer_size6_class2", + "ItemHealth": 1.0, + "On": true, + "Value": 497429 + }, + { + "Slot": "Slot03_Size6", + "Item": "int_shieldgenerator_size5_class2", + "ItemHealth": 1.0, + "On": true, + "Value": 165879 + }, + { + "Slot": "Slot04_Size6", + "Item": "int_dronecontrol_repair_size5_class2", + "ItemHealth": 1.0, + "On": true, + "Value": 85293 + }, + { + "Slot": "Slot05_Size5", + "Item": "int_guardianfsdbooster_size5", + "ItemHealth": 1.0, + "On": true, + "Value": 5688921 + }, + { + "Slot": "Slot07_Size4", + "Item": "int_cargorack_size4_class1", + "ItemHealth": 1.0, + "On": true, + "Priority": 1, + "Value": 30124 + }, + { + "Slot": "Slot11_Size3", + "Item": "int_detailedsurfacescanner_tiny", + "ItemHealth": 1.0, + "On": true, + "Value": 219375 + }, + { + "Slot": "Slot12_Size1", + "Item": "int_repairer_size1_class5", + "ItemHealth": 1.0, + "On": false, + "Value": 710775 + }, + { + "Slot": "PlanetaryApproachSuite", + "Item": "int_planetapproachsuite_advanced", + "ItemHealth": 1.0, + "On": true, + "Priority": 1 + }, + { + "Slot": "WeaponColour", + "Item": "weaponcustomisation_red", + "ItemHealth": 1.0, + "On": true, + "Priority": 1 + }, + { + "Slot": "EngineColour", + "Item": "enginecustomisation_orange", + "ItemHealth": 1.0, + "On": true, + "Priority": 1 + }, + { + "Slot": "VesselVoice", + "Item": "voicepack_verity", + "ItemHealth": 1.0, + "On": true, + "Priority": 1 + }, + { + "Slot": "ShipCockpit", + "Item": "belugaliner_cockpit", + "ItemHealth": 1.0, + "On": true, + "Priority": 1 + }, + { + "Slot": "CargoHatch", + "Item": "modularcargobaydoor", + "ItemHealth": 1.0, + "On": false, + "Priority": 1 + } + ] + } +} \ No newline at end of file diff --git a/plugins/inara.py b/plugins/inara.py index f2c9830e..1cae5c64 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -35,6 +35,7 @@ import requests import edmc_data import killswitch import myNotebook as nb # noqa: N813 +from edshipyard import ships import plug import timeout_session from companion import CAPIData @@ -870,6 +871,7 @@ def journal_entry( # noqa: C901, CCR001 cur_ship['shipRebuyCost'] = state['Rebuy'] new_add_event('setCommanderShip', entry['timestamp'], cur_ship) + make_slef(state, entry) # Stored modules if event_name == 'StoredModules': @@ -1476,6 +1478,57 @@ def make_loadout(state: dict[str, Any]) -> dict[str, Any]: # noqa: CCR001 } +def make_slef(state: dict[str, Any], entry) -> None: + initial_dict = { + "header": {"appName": appname, "appVersion": str(appversion())} + } + data_dict = {} + loadout = make_loadout(state) + modules = loadout['shipLoadout'] + mod_dict = [] + for module in modules: + if module['slotName']: + builder = { + 'Slot': module['slotName'], + 'Item': module['itemName'] + } + if module.get('itemHealth'): + builder.update({'ItemHealth': module['itemHealth']}) + if module.get('isOn'): + builder.update({'On': True}) + elif not module.get('isOn'): + builder.update({'On': False}) + if module.get('itemPriority'): + builder.update({'Priority': module['itemPriority']}) + if module.get('itemValue'): + builder.update({'Value': module['itemValue']}) + if not module.get('itemValue'): + builder.update({'Value': 0}) + if module.get('slotName') == 'FuelTank': + cap = module['itemName'].split('size') + cap = cap[1].split('_') + cap = 2**int(cap[0]) + ship = edmc_data.ship_name_map[state["ShipType"]] + fuel = {'Main': cap, 'Reserve': ships[ship]['reserveFuelCapacity']} + data_dict.update({"FuelCapacity": fuel}) + mod_dict.append(builder) + data_dict.update({ + 'Ship': state["ShipType"], + 'ShipName': state['ShipName'], + 'ShipIdent': state['ShipIdent'], + 'HullValue': state['HullValue'], + 'ModulesValue': state['ModulesValue'], + 'Rebuy': state['Rebuy'], + 'MaxJumpRange': entry['MaxJumpRange'], + 'UnladenMass': entry['UnladenMass'], + 'CargoCapacity': entry['CargoCapacity'], + 'Modules': mod_dict, + }) + initial_dict.update({'data': data_dict}) + json.dump(initial_dict, open('inara.json', 'w'), indent=4) + return None + + def new_add_event( name: str, timestamp: str, diff --git a/ships.json b/ships.json index 65a2989e..ac05d5d8 100644 --- a/ships.json +++ b/ships.json @@ -1,119 +1,158 @@ { "Adder": { - "hullMass": 35 + "hullMass": 35, + "reserveFuelCapacity": 0.36 }, "Alliance Challenger": { - "hullMass": 450 + "hullMass": 450, + "reserveFuelCapacity": 0.77 }, "Alliance Chieftain": { - "hullMass": 400 + "hullMass": 400, + "reserveFuelCapacity": 0.77 }, "Alliance Crusader": { - "hullMass": 500 + "hullMass": 500, + "reserveFuelCapacity": 0.77 }, "Anaconda": { - "hullMass": 400 + "hullMass": 400, + "reserveFuelCapacity": 1.07 }, "Asp Explorer": { - "hullMass": 280 + "hullMass": 280, + "reserveFuelCapacity": 0.63 }, "Asp Scout": { - "hullMass": 150 + "hullMass": 150, + "reserveFuelCapacity": 0.47 }, "Beluga Liner": { - "hullMass": 950 + "hullMass": 950, + "reserveFuelCapacity": 0.81 }, "Cobra MkIII": { - "hullMass": 180 + "hullMass": 180, + "reserveFuelCapacity": 0.49 }, "Cobra MkIV": { - "hullMass": 210 + "hullMass": 210, + "reserveFuelCapacity": 0.51 }, "Diamondback Explorer": { - "hullMass": 260 + "hullMass": 260, + "reserveFuelCapacity": 0.52 }, "Diamondback Scout": { - "hullMass": 170 + "hullMass": 170, + "reserveFuelCapacity": 0.49 }, "Dolphin": { - "hullMass": 140 + "hullMass": 140, + "reserveFuelCapacity": 0.5 }, "Eagle": { - "hullMass": 50 + "hullMass": 50, + "reserveFuelCapacity": 0.34 }, "Federal Assault Ship": { - "hullMass": 480 + "hullMass": 480, + "reserveFuelCapacity": 0.72 }, "Federal Corvette": { - "hullMass": 900 + "hullMass": 900, + "reserveFuelCapacity": 1.13 }, "Federal Dropship": { - "hullMass": 580 + "hullMass": 580, + "reserveFuelCapacity": 0.83 }, "Federal Gunship": { - "hullMass": 580 + "hullMass": 580, + "reserveFuelCapacity": 0.82 }, "Fer-de-Lance": { - "hullMass": 250 + "hullMass": 250, + "reserveFuelCapacity": 0.67 }, "Hauler": { - "hullMass": 14 + "hullMass": 14, + "reserveFuelCapacity": 0.25 }, "Imperial Clipper": { - "hullMass": 400 + "hullMass": 400, + "reserveFuelCapacity": 0.74 }, "Imperial Courier": { - "hullMass": 35 + "hullMass": 35, + "reserveFuelCapacity": 0.41 }, "Imperial Cutter": { - "hullMass": 1100 + "hullMass": 1100, + "reserveFuelCapacity": 1.16 }, "Imperial Eagle": { - "hullMass": 50 + "hullMass": 50, + "reserveFuelCapacity": 0.37 }, "Keelback": { - "hullMass": 180 + "hullMass": 180, + "reserveFuelCapacity": 0.39 }, "Krait MkII": { - "hullMass": 320 + "hullMass": 320, + "reserveFuelCapacity": 0.63 }, "Krait Phantom": { - "hullMass": 270 + "hullMass": 270, + "reserveFuelCapacity": 0.63 }, "Mamba": { - "hullMass": 250 + "hullMass": 250, + "reserveFuelCapacity": 0.5 }, "Orca": { - "hullMass": 290 + "hullMass": 290, + "reserveFuelCapacity": 0.79 }, "Python": { - "hullMass": 350 + "hullMass": 350, + "reserveFuelCapacity": 0.83 }, "Python Mk II": { - "hullMass": 450 + "hullMass": 450, + "reserveFuelCapacity": 0.83 }, "Sidewinder": { - "hullMass": 25 + "hullMass": 25, + "reserveFuelCapacity": 0.3 }, "Type-10 Defender": { - "hullMass": 1200 + "hullMass": 1200, + "reserveFuelCapacity": 0.77 }, "Type-6 Transporter": { - "hullMass": 155 + "hullMass": 155, + "reserveFuelCapacity": 0.39 }, "Type-7 Transporter": { - "hullMass": 350 + "hullMass": 350, + "reserveFuelCapacity": 0.52 }, "Type-9 Heavy": { - "hullMass": 850 + "hullMass": 850, + "reserveFuelCapacity": 0.77 }, "Viper MkIII": { - "hullMass": 50 + "hullMass": 50, + "reserveFuelCapacity": 0.41 }, "Viper MkIV": { - "hullMass": 190 + "hullMass": 190, + "reserveFuelCapacity": 0.46 }, "Vulture": { - "hullMass": 230 + "hullMass": 230, + "reserveFuelCapacity": 0.57 } } \ No newline at end of file From fb1e3dcab6268a56cad742b3fcf259c3ba17450f Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Mon, 17 Jun 2024 14:51:56 -0400 Subject: [PATCH 06/22] [Minor] Fix MyPy Complaint --- scripts/build_changelog.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build_changelog.py b/scripts/build_changelog.py index f0c01994..6b050774 100644 --- a/scripts/build_changelog.py +++ b/scripts/build_changelog.py @@ -34,9 +34,9 @@ def get_changelog() -> tuple[str, str]: changelog[1] = "\n".join(changelog[1].strip().split("\n")[:-2]) version = changelog[0] version = version.split(" ")[1] - changelog = changelog[1].strip() + final_changelog = changelog[1].strip() - return changelog, version + return final_changelog, version def build_html(md_changelog: str, version: str) -> str: From 87f59a54fa41c1333e0fae680884a4da59a8c2fb Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Mon, 17 Jun 2024 16:38:20 -0400 Subject: [PATCH 07/22] [RELEASE] 5.10.2 --- ChangeLog.md | 12 ++++++++++++ config/__init__.py | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 1c2ac9c2..2f9248f1 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -6,6 +6,18 @@ This is the master changelog for Elite Dangerous Market Connector. Entries are in the source (not distributed with the Windows installer) for the currently used version. --- +Release 5.11.2 +=== + +This release fixes a bug where minimizing to the system tray could cause the program to not un-minimize. + +**Changes and Enhancements** +* Updated Translations +* Added a developer utilty to help speed up changelog development + +**Bug Fixes** +* Fixed a bug where minimizing to the system tray could cause the program to not un-minimize. + Release 5.11.1 === diff --git a/config/__init__.py b/config/__init__.py index 8dfcf46b..4fe565e4 100644 --- a/config/__init__.py +++ b/config/__init__.py @@ -52,7 +52,7 @@ appcmdname = 'EDMC' # # Major.Minor.Patch(-prerelease)(+buildmetadata) # NB: Do *not* import this, use the functions appversion() and appversion_nobuild() -_static_appversion = '5.11.1' +_static_appversion = '5.11.2' _cached_version: semantic_version.Version | None = None copyright = '© 2015-2019 Jonathan Harris, 2020-2024 EDCD' From 0aa1128094e36a09e4293096ad40d064c00ba96e Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Mon, 17 Jun 2024 17:09:30 -0400 Subject: [PATCH 08/22] [Docs] Fix Typo in Changelog >:( --- ChangeLog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 2f9248f1..30023566 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -13,7 +13,7 @@ This release fixes a bug where minimizing to the system tray could cause the pro **Changes and Enhancements** * Updated Translations -* Added a developer utilty to help speed up changelog development +* Added a developer utility to help speed up changelog development **Bug Fixes** * Fixed a bug where minimizing to the system tray could cause the program to not un-minimize. From d478a68bc61de1fdc20c6ca526e4c1740944e672 Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Tue, 18 Jun 2024 21:15:11 -0400 Subject: [PATCH 09/22] [2262] Simplify SLEF Building --- plugins/inara.py | 55 +++++++++++++++--------------------------------- 1 file changed, 17 insertions(+), 38 deletions(-) diff --git a/plugins/inara.py b/plugins/inara.py index 1cae5c64..3fd42f34 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -871,7 +871,7 @@ def journal_entry( # noqa: C901, CCR001 cur_ship['shipRebuyCost'] = state['Rebuy'] new_add_event('setCommanderShip', entry['timestamp'], cur_ship) - make_slef(state, entry) + make_slef(entry) # Stored modules if event_name == 'StoredModules': @@ -1478,51 +1478,30 @@ def make_loadout(state: dict[str, Any]) -> dict[str, Any]: # noqa: CCR001 } -def make_slef(state: dict[str, Any], entry) -> None: +def make_slef(entry) -> None: initial_dict = { "header": {"appName": appname, "appVersion": str(appversion())} } data_dict = {} - loadout = make_loadout(state) - modules = loadout['shipLoadout'] - mod_dict = [] - for module in modules: - if module['slotName']: - builder = { - 'Slot': module['slotName'], - 'Item': module['itemName'] - } - if module.get('itemHealth'): - builder.update({'ItemHealth': module['itemHealth']}) - if module.get('isOn'): - builder.update({'On': True}) - elif not module.get('isOn'): - builder.update({'On': False}) - if module.get('itemPriority'): - builder.update({'Priority': module['itemPriority']}) - if module.get('itemValue'): - builder.update({'Value': module['itemValue']}) - if not module.get('itemValue'): - builder.update({'Value': 0}) - if module.get('slotName') == 'FuelTank': - cap = module['itemName'].split('size') - cap = cap[1].split('_') - cap = 2**int(cap[0]) - ship = edmc_data.ship_name_map[state["ShipType"]] - fuel = {'Main': cap, 'Reserve': ships[ship]['reserveFuelCapacity']} - data_dict.update({"FuelCapacity": fuel}) - mod_dict.append(builder) + for module in entry['Modules']: + if module.get('Slot') == 'FuelTank': + cap = module['Item'].split('size') + cap = cap[1].split('_') + cap = 2 ** int(cap[0]) + ship = edmc_data.ship_name_map[entry["Ship"]] + fuel = {'Main': cap, 'Reserve': ships[ship]['reserveFuelCapacity']} + data_dict.update({"FuelCapacity": fuel}) data_dict.update({ - 'Ship': state["ShipType"], - 'ShipName': state['ShipName'], - 'ShipIdent': state['ShipIdent'], - 'HullValue': state['HullValue'], - 'ModulesValue': state['ModulesValue'], - 'Rebuy': state['Rebuy'], + 'Ship': entry["Ship"], + 'ShipName': entry['ShipName'], + 'ShipIdent': entry['ShipIdent'], + 'HullValue': entry['HullValue'], + 'ModulesValue': entry['ModulesValue'], + 'Rebuy': entry['Rebuy'], 'MaxJumpRange': entry['MaxJumpRange'], 'UnladenMass': entry['UnladenMass'], 'CargoCapacity': entry['CargoCapacity'], - 'Modules': mod_dict, + 'Modules': entry['Modules'], }) initial_dict.update({'data': data_dict}) json.dump(initial_dict, open('inara.json', 'w'), indent=4) From 0cc35db96b560f971a78b3d4f30003a37805bc18 Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Tue, 18 Jun 2024 22:02:41 -0400 Subject: [PATCH 10/22] [2262] SLEF to this var --- plugins/inara.py | 6 +++++- ttkHyperlinkLabel.py | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/plugins/inara.py b/plugins/inara.py index 3fd42f34..c3f030c4 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -107,6 +107,7 @@ class This: self.fleet: list[dict[str, Any]] | None = None self.shipswap: bool = False # just swapped ship self.on_foot = False + self.SLEF: str | None = None self.timer_run = True @@ -1504,7 +1505,10 @@ def make_slef(entry) -> None: 'Modules': entry['Modules'], }) initial_dict.update({'data': data_dict}) - json.dump(initial_dict, open('inara.json', 'w'), indent=4) + output = json.dumps(initial_dict, indent=4) + this.SLEF = str(output) + print('set output') + print(type(this.SLEF)) return None diff --git a/ttkHyperlinkLabel.py b/ttkHyperlinkLabel.py index 6266d9fb..95ebd2e7 100644 --- a/ttkHyperlinkLabel.py +++ b/ttkHyperlinkLabel.py @@ -194,6 +194,11 @@ class HyperlinkLabel(tk.Label or ttk.Label): # type: ignore menu.add_command(label=tr.tl('Copy'), command=self.copy) # As in Copy and Paste if self.name == 'ship': + # TODO: Get SLEF from Inara + # print(self.SLEF) + # menu.add_command(label=tr.tl('Copy INARA SLEF'), command=lambda: self.copy_slef(self), state=tk.DISABLED) + # menu.entryconfigure(1, state=self.SLEF and tk.NORMAL or tk.DISABLED) + menu.add_separator() for url in plug.provides('shipyard_url'): menu.add_command( @@ -224,3 +229,8 @@ class HyperlinkLabel(tk.Label or ttk.Label): # type: ignore """Copy the current text to the clipboard.""" self.clipboard_clear() self.clipboard_append(self['text']) + + # def copy_slef(self, this) -> None: + # """Copy the current text to the clipboard.""" + # self.clipboard_clear() + # self.clipboard_append(this.SLEF) From 3b6259276a9fdfb606abbd59fd8aca488f1c32e3 Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Sun, 23 Jun 2024 13:05:39 -0400 Subject: [PATCH 11/22] [2262] Move SLEF to Monitor --- inara.json | 267 ------------------------------------------- monitor.py | 34 +++++- plugins/inara.py | 35 ------ ttkHyperlinkLabel.py | 14 +-- 4 files changed, 39 insertions(+), 311 deletions(-) delete mode 100644 inara.json diff --git a/inara.json b/inara.json deleted file mode 100644 index 1c5cba8a..00000000 --- a/inara.json +++ /dev/null @@ -1,267 +0,0 @@ -{ - "header": { - "appName": "EDMarketConnector", - "appVersion": "5.11.1+85f5c328.DIRTY" - }, - "data": { - "FuelCapacity": { - "Main": 128, - "Reserve": 0.81 - }, - "Ship": "belugaliner", - "ShipName": "HSRV Guiding Light", - "ShipIdent": "NFC-23", - "HullValue": 69924158, - "ModulesValue": 96918434, - "Rebuy": 8342132, - "MaxJumpRange": 52.615143, - "UnladenMass": 1233.057983, - "CargoCapacity": 16, - "Modules": [ - { - "Slot": "TinyHardpoint1", - "Item": "hpt_heatsinklauncher_turret_tiny", - "ItemHealth": 1.0, - "On": true, - "Value": 3072 - }, - { - "Slot": "TinyHardpoint2", - "Item": "hpt_heatsinklauncher_turret_tiny", - "ItemHealth": 1.0, - "On": true, - "Value": 3413 - }, - { - "Slot": "TinyHardpoint3", - "Item": "hpt_heatsinklauncher_turret_tiny", - "ItemHealth": 1.0, - "On": true, - "Value": 3072 - }, - { - "Slot": "TinyHardpoint4", - "Item": "hpt_heatsinklauncher_turret_tiny", - "ItemHealth": 1.0, - "On": true, - "Value": 3072 - }, - { - "Slot": "PaintJob", - "Item": "paintjob_belugaliner_lrpo_azure", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "Armour", - "Item": "belugaliner_armour_grade1", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "PowerPlant", - "Item": "int_powerplant_size6_class5", - "ItemHealth": 1.0, - "On": true, - "Priority": 1, - "Value": 11382139 - }, - { - "Slot": "MainEngines", - "Item": "int_engine_size7_class2", - "ItemHealth": 1.0, - "On": true, - "Priority": 1, - "Value": 1666898 - }, - { - "Slot": "FrameShiftDrive", - "Item": "int_hyperdrive_size7_class5", - "ItemHealth": 1.0, - "On": true, - "Value": 45006196 - }, - { - "Slot": "LifeSupport", - "Item": "int_lifesupport_size8_class2", - "ItemHealth": 1.0, - "On": true, - "Value": 1530326 - }, - { - "Slot": "PowerDistributor", - "Item": "int_powerdistributor_size6_class5", - "ItemHealth": 1.0, - "On": true, - "Priority": 1, - "Value": 3049917 - }, - { - "Slot": "Radar", - "Item": "int_sensors_size5_class2", - "ItemHealth": 1.0, - "On": true, - "Priority": 1, - "Value": 69713 - }, - { - "Slot": "FuelTank", - "Item": "int_fueltank_size7_class3", - "ItemHealth": 1.0, - "On": true, - "Priority": 1, - "Value": 1562752 - }, - { - "Slot": "Decal1", - "Item": "decal_distantworlds2", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "Decal2", - "Item": "decal_distantworlds2", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "Decal3", - "Item": "decal_distantworlds2", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "ShipName0", - "Item": "nameplate_practical01_black", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "ShipName1", - "Item": "nameplate_practical01_black", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "ShipID0", - "Item": "nameplate_shipid_singleline_black", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "ShipID1", - "Item": "nameplate_shipid_singleline_black", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "Slot01_Size6", - "Item": "int_fuelscoop_size6_class5", - "ItemHealth": 1.0, - "On": true, - "Value": 25240068 - }, - { - "Slot": "Slot02_Size6", - "Item": "int_repairer_size6_class2", - "ItemHealth": 1.0, - "On": true, - "Value": 497429 - }, - { - "Slot": "Slot03_Size6", - "Item": "int_shieldgenerator_size5_class2", - "ItemHealth": 1.0, - "On": true, - "Value": 165879 - }, - { - "Slot": "Slot04_Size6", - "Item": "int_dronecontrol_repair_size5_class2", - "ItemHealth": 1.0, - "On": true, - "Value": 85293 - }, - { - "Slot": "Slot05_Size5", - "Item": "int_guardianfsdbooster_size5", - "ItemHealth": 1.0, - "On": true, - "Value": 5688921 - }, - { - "Slot": "Slot07_Size4", - "Item": "int_cargorack_size4_class1", - "ItemHealth": 1.0, - "On": true, - "Priority": 1, - "Value": 30124 - }, - { - "Slot": "Slot11_Size3", - "Item": "int_detailedsurfacescanner_tiny", - "ItemHealth": 1.0, - "On": true, - "Value": 219375 - }, - { - "Slot": "Slot12_Size1", - "Item": "int_repairer_size1_class5", - "ItemHealth": 1.0, - "On": false, - "Value": 710775 - }, - { - "Slot": "PlanetaryApproachSuite", - "Item": "int_planetapproachsuite_advanced", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "WeaponColour", - "Item": "weaponcustomisation_red", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "EngineColour", - "Item": "enginecustomisation_orange", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "VesselVoice", - "Item": "voicepack_verity", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "ShipCockpit", - "Item": "belugaliner_cockpit", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "CargoHatch", - "Item": "modularcargobaydoor", - "ItemHealth": 1.0, - "On": false, - "Priority": 1 - } - ] - } -} \ No newline at end of file diff --git a/monitor.py b/monitor.py index 9d33f5eb..ae0f3ad7 100644 --- a/monitor.py +++ b/monitor.py @@ -21,9 +21,10 @@ from time import gmtime, localtime, mktime, sleep, strftime, strptime, time from typing import TYPE_CHECKING, Any, BinaryIO, MutableMapping import semantic_version import util_ships -from config import config -from edmc_data import edmc_suit_shortnames, edmc_suit_symbol_localised +from config import config, appname, appversion +from edmc_data import edmc_suit_shortnames, edmc_suit_symbol_localised, ship_name_map from EDMCLogging import get_main_logger +from edshipyard import ships if TYPE_CHECKING: import tkinter @@ -109,6 +110,7 @@ class EDLogs(FileSystemEventHandler): self.group: str | None = None self.cmdr: str | None = None self.started: int | None = None # Timestamp of the LoadGame event + self.slef: str | None = None self._navroute_retries_remaining = 0 self._last_navroute_journal_timestamp: float | None = None @@ -701,6 +703,34 @@ class EDLogs(FileSystemEventHandler): module.pop('AmmoInHopper') self.state['Modules'][module['Slot']] = module + # SLEF + initial_dict = { + "header": {"appName": appname, "appVersion": str(appversion())} + } + data_dict = {} + for module in entry['Modules']: + if module.get('Slot') == 'FuelTank': + cap = module['Item'].split('size') + cap = cap[1].split('_') + cap = 2 ** int(cap[0]) + ship = ship_name_map[entry["Ship"]] + fuel = {'Main': cap, 'Reserve': ships[ship]['reserveFuelCapacity']} + data_dict.update({"FuelCapacity": fuel}) + data_dict.update({ + 'Ship': entry["Ship"], + 'ShipName': entry['ShipName'], + 'ShipIdent': entry['ShipIdent'], + 'HullValue': entry['HullValue'], + 'ModulesValue': entry['ModulesValue'], + 'Rebuy': entry['Rebuy'], + 'MaxJumpRange': entry['MaxJumpRange'], + 'UnladenMass': entry['UnladenMass'], + 'CargoCapacity': entry['CargoCapacity'], + 'Modules': entry['Modules'], + }) + initial_dict.update({'data': data_dict}) + output = json.dumps(initial_dict, indent=4) + self.slef = str(output) elif event_type == 'modulebuy': self.state['Modules'][entry['Slot']] = { diff --git a/plugins/inara.py b/plugins/inara.py index c3f030c4..a4cc0e55 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -35,7 +35,6 @@ import requests import edmc_data import killswitch import myNotebook as nb # noqa: N813 -from edshipyard import ships import plug import timeout_session from companion import CAPIData @@ -872,7 +871,6 @@ def journal_entry( # noqa: C901, CCR001 cur_ship['shipRebuyCost'] = state['Rebuy'] new_add_event('setCommanderShip', entry['timestamp'], cur_ship) - make_slef(entry) # Stored modules if event_name == 'StoredModules': @@ -1479,39 +1477,6 @@ def make_loadout(state: dict[str, Any]) -> dict[str, Any]: # noqa: CCR001 } -def make_slef(entry) -> None: - initial_dict = { - "header": {"appName": appname, "appVersion": str(appversion())} - } - data_dict = {} - for module in entry['Modules']: - if module.get('Slot') == 'FuelTank': - cap = module['Item'].split('size') - cap = cap[1].split('_') - cap = 2 ** int(cap[0]) - ship = edmc_data.ship_name_map[entry["Ship"]] - fuel = {'Main': cap, 'Reserve': ships[ship]['reserveFuelCapacity']} - data_dict.update({"FuelCapacity": fuel}) - data_dict.update({ - 'Ship': entry["Ship"], - 'ShipName': entry['ShipName'], - 'ShipIdent': entry['ShipIdent'], - 'HullValue': entry['HullValue'], - 'ModulesValue': entry['ModulesValue'], - 'Rebuy': entry['Rebuy'], - 'MaxJumpRange': entry['MaxJumpRange'], - 'UnladenMass': entry['UnladenMass'], - 'CargoCapacity': entry['CargoCapacity'], - 'Modules': entry['Modules'], - }) - initial_dict.update({'data': data_dict}) - output = json.dumps(initial_dict, indent=4) - this.SLEF = str(output) - print('set output') - print(type(this.SLEF)) - return None - - def new_add_event( name: str, timestamp: str, diff --git a/ttkHyperlinkLabel.py b/ttkHyperlinkLabel.py index 95ebd2e7..5ca4feb4 100644 --- a/ttkHyperlinkLabel.py +++ b/ttkHyperlinkLabel.py @@ -195,9 +195,9 @@ class HyperlinkLabel(tk.Label or ttk.Label): # type: ignore if self.name == 'ship': # TODO: Get SLEF from Inara - # print(self.SLEF) - # menu.add_command(label=tr.tl('Copy INARA SLEF'), command=lambda: self.copy_slef(self), state=tk.DISABLED) - # menu.entryconfigure(1, state=self.SLEF and tk.NORMAL or tk.DISABLED) + print(bool(monitor.slef)) + menu.add_command(label=tr.tl('Copy INARA SLEF'), command=self.copy_slef, state=tk.DISABLED) + menu.entryconfigure(1, state=monitor.slef and tk.NORMAL or tk.DISABLED) menu.add_separator() for url in plug.provides('shipyard_url'): @@ -230,7 +230,7 @@ class HyperlinkLabel(tk.Label or ttk.Label): # type: ignore self.clipboard_clear() self.clipboard_append(self['text']) - # def copy_slef(self, this) -> None: - # """Copy the current text to the clipboard.""" - # self.clipboard_clear() - # self.clipboard_append(this.SLEF) + def copy_slef(self) -> None: + """Copy the current text to the clipboard.""" + self.clipboard_clear() + self.clipboard_append(monitor.slef) From 47192ce674375f4b87590167919547c25a070d92 Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Sun, 23 Jun 2024 13:06:52 -0400 Subject: [PATCH 12/22] [2262] Remove Dev self.SLEF --- plugins/inara.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/inara.py b/plugins/inara.py index a4cc0e55..f2c9830e 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -106,7 +106,6 @@ class This: self.fleet: list[dict[str, Any]] | None = None self.shipswap: bool = False # just swapped ship self.on_foot = False - self.SLEF: str | None = None self.timer_run = True From d9f7b72e4655777b70ec4e1cfa0b4183231fe518 Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Sun, 23 Jun 2024 13:09:13 -0400 Subject: [PATCH 13/22] [2262] Update Type Hinting --- monitor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monitor.py b/monitor.py index ae0f3ad7..29970ec0 100644 --- a/monitor.py +++ b/monitor.py @@ -704,7 +704,7 @@ class EDLogs(FileSystemEventHandler): self.state['Modules'][module['Slot']] = module # SLEF - initial_dict = { + initial_dict: dict[str, dict[str, Any]] = { "header": {"appName": appname, "appVersion": str(appversion())} } data_dict = {} From 5a9970e6c7cf2191662ebde0bf9d0fa873d7acd6 Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Sun, 23 Jun 2024 13:10:57 -0400 Subject: [PATCH 14/22] [2262] Remove Debug Code --- ttkHyperlinkLabel.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/ttkHyperlinkLabel.py b/ttkHyperlinkLabel.py index 5ca4feb4..6678530a 100644 --- a/ttkHyperlinkLabel.py +++ b/ttkHyperlinkLabel.py @@ -194,8 +194,6 @@ class HyperlinkLabel(tk.Label or ttk.Label): # type: ignore menu.add_command(label=tr.tl('Copy'), command=self.copy) # As in Copy and Paste if self.name == 'ship': - # TODO: Get SLEF from Inara - print(bool(monitor.slef)) menu.add_command(label=tr.tl('Copy INARA SLEF'), command=self.copy_slef, state=tk.DISABLED) menu.entryconfigure(1, state=monitor.slef and tk.NORMAL or tk.DISABLED) From 067bef628e64716c3bd655e52369d2de474f09ad Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Sun, 23 Jun 2024 13:14:41 -0400 Subject: [PATCH 15/22] [2262] Update Capitalizations and add Translations --- L10n/en.template | 3 +++ ttkHyperlinkLabel.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/L10n/en.template b/L10n/en.template index 1c1e110f..34734787 100644 --- a/L10n/en.template +++ b/L10n/en.template @@ -813,3 +813,6 @@ /* ttkHyperlinkLabel.py: Open Element In Selected Provider; */ "Open in {URL}" = "Open in {URL}"; + +/* ttkHyperlinkLabel.py: Copy the Inara SLEF Format of the active ship to the clipboard; */ +"Copy Inara SLEF" = "Copy Inara SLEF"; diff --git a/ttkHyperlinkLabel.py b/ttkHyperlinkLabel.py index 6678530a..9f445690 100644 --- a/ttkHyperlinkLabel.py +++ b/ttkHyperlinkLabel.py @@ -194,7 +194,8 @@ class HyperlinkLabel(tk.Label or ttk.Label): # type: ignore menu.add_command(label=tr.tl('Copy'), command=self.copy) # As in Copy and Paste if self.name == 'ship': - menu.add_command(label=tr.tl('Copy INARA SLEF'), command=self.copy_slef, state=tk.DISABLED) + # LANG: Copy the Inara SLEF Format of the active ship to the clipboard + menu.add_command(label=tr.tl('Copy Inara SLEF'), command=self.copy_slef, state=tk.DISABLED) menu.entryconfigure(1, state=monitor.slef and tk.NORMAL or tk.DISABLED) menu.add_separator() From 19c91511359812f7c1b8bb920e50014e26b564b6 Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Sun, 23 Jun 2024 13:26:44 -0400 Subject: [PATCH 16/22] [2262] Format SLEF with Square Brackets --- monitor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monitor.py b/monitor.py index 29970ec0..b11301b8 100644 --- a/monitor.py +++ b/monitor.py @@ -730,7 +730,7 @@ class EDLogs(FileSystemEventHandler): }) initial_dict.update({'data': data_dict}) output = json.dumps(initial_dict, indent=4) - self.slef = str(output) + self.slef = str(f"[{output}]") elif event_type == 'modulebuy': self.state['Modules'][entry['Slot']] = { From a385b6fd80b994f9aa414a39155ec5b26f509eeb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 17:38:51 +0000 Subject: [PATCH 17/22] Bump flake8 from 7.0.0 to 7.1.0 Bumps [flake8](https://github.com/pycqa/flake8) from 7.0.0 to 7.1.0. - [Commits](https://github.com/pycqa/flake8/compare/7.0.0...7.1.0) --- updated-dependencies: - dependency-name: flake8 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 05c5ad29..28a239d2 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -8,7 +8,7 @@ wheel setuptools==70.0.0 # Static analysis tools -flake8==7.0.0 +flake8==7.1.0 flake8-annotations-coverage==0.0.6 flake8-cognitive-complexity==0.1.0 flake8-comprehensions==3.14.0 From 0adc9cbe63311c967c7a4b42e96cb513868fd886 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 17:38:56 +0000 Subject: [PATCH 18/22] Bump pep8-naming from 0.13.3 to 0.14.1 Bumps [pep8-naming](https://github.com/PyCQA/pep8-naming) from 0.13.3 to 0.14.1. - [Release notes](https://github.com/PyCQA/pep8-naming/releases) - [Changelog](https://github.com/PyCQA/pep8-naming/blob/main/CHANGELOG.rst) - [Commits](https://github.com/PyCQA/pep8-naming/compare/0.13.3...0.14.1) --- updated-dependencies: - dependency-name: pep8-naming dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 05c5ad29..68062755 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -19,7 +19,7 @@ flake8-polyfill==1.0.2 flake8-use-fstring==1.4 mypy==1.10.0 -pep8-naming==0.13.3 +pep8-naming==0.14.1 safety==3.2.0 types-requests==2.31.0.20240311 types-pkg-resources==0.1.3 From 47b621c2b8abf451952dbe9f41a0c0a11bb71259 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 17:38:59 +0000 Subject: [PATCH 19/22] Bump watchdog from 4.0.0 to 4.0.1 Bumps [watchdog](https://github.com/gorakhargosh/watchdog) from 4.0.0 to 4.0.1. - [Release notes](https://github.com/gorakhargosh/watchdog/releases) - [Changelog](https://github.com/gorakhargosh/watchdog/blob/master/changelog.rst) - [Commits](https://github.com/gorakhargosh/watchdog/compare/v4.0.0...v4.0.1) --- updated-dependencies: - dependency-name: watchdog dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 22f0a360..87795065 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ requests==2.32.3 pillow==10.3.0 -watchdog==4.0.0 +watchdog==4.0.1 simplesystray==0.1.0; sys_platform == 'win32' semantic-version==2.10.0 From bac4b30848293bccf224bf505203e827c7982260 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 17:39:04 +0000 Subject: [PATCH 20/22] Bump pytest from 8.2.0 to 8.2.2 Bumps [pytest](https://github.com/pytest-dev/pytest) from 8.2.0 to 8.2.2. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/8.2.0...8.2.2) --- updated-dependencies: - dependency-name: pytest dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 05c5ad29..9c4f249d 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -38,7 +38,7 @@ mistune==3.0.2 py2exe==0.13.0.1; sys_platform == 'win32' # Testing -pytest==8.2.0 +pytest==8.2.2 pytest-cov==5.0.0 # Pytest code coverage support coverage[toml]==7.5.0 # pytest-cov dep. This is here to ensure that it includes TOML support for pyproject.toml configs coverage-conditional-plugin==0.9.0 From 054245f34848679d11a4771b38c66f4d1081a6df Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 18:46:54 +0000 Subject: [PATCH 21/22] Bump flake8-comprehensions from 3.14.0 to 3.15.0 Bumps [flake8-comprehensions](https://github.com/adamchainz/flake8-comprehensions) from 3.14.0 to 3.15.0. - [Changelog](https://github.com/adamchainz/flake8-comprehensions/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamchainz/flake8-comprehensions/compare/3.14.0...3.15.0) --- updated-dependencies: - dependency-name: flake8-comprehensions dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 2f27e2ab..fe145993 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -11,7 +11,7 @@ setuptools==70.0.0 flake8==7.1.0 flake8-annotations-coverage==0.0.6 flake8-cognitive-complexity==0.1.0 -flake8-comprehensions==3.14.0 +flake8-comprehensions==3.15.0 flake8-docstrings==1.7.0 flake8-json==24.4.0 flake8-noqa==1.4.0 From e9755fae783bfce12ed05928d5d93e2e510ac1a5 Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Mon, 1 Jul 2024 14:56:51 -0400 Subject: [PATCH 22/22] [2270] C420 Unnecessary Dict Comprehension --- debug_webserver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug_webserver.py b/debug_webserver.py index 87f7eaed..1825c771 100644 --- a/debug_webserver.py +++ b/debug_webserver.py @@ -18,7 +18,7 @@ logger = get_main_logger() output_lock = threading.Lock() output_data_path = pathlib.Path(tempfile.gettempdir()) / f'{appname}' / 'http_debug' -SAFE_TRANSLATE = str.maketrans({x: '_' for x in "!@#$%^&*()./\\\r\n[]-+='\";:?<>,~`"}) +SAFE_TRANSLATE = str.maketrans(dict.fromkeys("!@#$%^&*()./\\\r\n[]-+='\";:?<>,~`", '_')) class LoggingHandler(server.BaseHTTPRequestHandler):