From a90b41a8cc7b0014145fe30c6acb3aadd3347295 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Fri, 2 Apr 2021 21:50:17 +0300 Subject: [PATCH 1/2] fix "module not found" errors when importing Python code from script-resources --- pyrightconfig.json | 8 ++++++++ scripts/copy-crosscode-emoji-url | 3 +-- scripts/query-bookmarks | 3 +-- 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 pyrightconfig.json diff --git a/pyrightconfig.json b/pyrightconfig.json new file mode 100644 index 0000000..741e0a1 --- /dev/null +++ b/pyrightconfig.json @@ -0,0 +1,8 @@ +{ + "executionEnvironments": [ + { + "root": "scripts", + "extraPaths": ["script-resources"] + } + ] +} diff --git a/scripts/copy-crosscode-emoji-url b/scripts/copy-crosscode-emoji-url index 520b8e1..2189e10 100755 --- a/scripts/copy-crosscode-emoji-url +++ b/scripts/copy-crosscode-emoji-url @@ -8,8 +8,7 @@ import urllib.parse import urllib.request sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "script-resources")) - -import common_script_utils # noqa: E402 +import common_script_utils DEFAULT_REGISTRY_DUMP_URL = "https://stronghold.crosscode.ru/~ccbot/emote-registry.json" diff --git a/scripts/query-bookmarks b/scripts/query-bookmarks index 1014eac..5b7023c 100755 --- a/scripts/query-bookmarks +++ b/scripts/query-bookmarks @@ -17,8 +17,7 @@ import sqlite3 import collections sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "script-resources")) - -import common_script_utils # noqa: E402 +import common_script_utils if sys.platform == "darwin": From 8dfc96c910b9d4f32253a419dd08930cd6384bf1 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Fri, 2 Apr 2021 21:51:47 +0300 Subject: [PATCH 2/2] import scripts from dmitmel/factorio-tools@8f8f9725e5a2f5a44685d382d979ff3e60ac7589 written on 2020-05-25 --- script-resources/factorio/property_tree.py | 65 ++++++++++++++++++++++ scripts/factorio-dump-mod-settings | 36 ++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 script-resources/factorio/property_tree.py create mode 100755 scripts/factorio-dump-mod-settings diff --git a/script-resources/factorio/property_tree.py b/script-resources/factorio/property_tree.py new file mode 100644 index 0000000..24629e2 --- /dev/null +++ b/script-resources/factorio/property_tree.py @@ -0,0 +1,65 @@ +# +# +# +# +# + +import struct + + +def read_bool(buf): + return buf.read(1)[0] == 1 + + +def read_number(buf): + return struct.unpack(" +# +# +# + +import sys +import os +from pathlib import Path +import struct +import json + +sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "script-resources")) +import factorio.property_tree + + +with open(Path.home() / ".factorio" / "mods" / "mod-settings.dat", "rb") as f: + + version_main, version_major, version_minor, version_developer = struct.unpack( + "