mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
Compare commits
No commits in common. "49b67aea8dcde8a85ba7cfdbe3875f38bc337f1a" and "23a741be948f8fd3715d593d7d5e9a181d9ffc6a" have entirely different histories.
49b67aea8d
...
23a741be94
5 changed files with 4 additions and 111 deletions
|
@ -1,8 +0,0 @@
|
||||||
{
|
|
||||||
"executionEnvironments": [
|
|
||||||
{
|
|
||||||
"root": "scripts",
|
|
||||||
"extraPaths": ["script-resources"]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,65 +0,0 @@
|
||||||
# <https://wiki.factorio.com/Property_tree>
|
|
||||||
# <factorio.https://wiki.factorio.com/Data_types>
|
|
||||||
# <https://github.com/credomane/factoriomodsettings/blob/master/src/ModSettingsDeserialiser.js>
|
|
||||||
# <https://github.com/credomane/factoriomodsettings/blob/master/src/ModSettingsSerialiser.js>
|
|
||||||
# <https://www.devdungeon.com/content/working-binary-data-python>
|
|
||||||
|
|
||||||
import struct
|
|
||||||
|
|
||||||
|
|
||||||
def read_bool(buf):
|
|
||||||
return buf.read(1)[0] == 1
|
|
||||||
|
|
||||||
|
|
||||||
def read_number(buf):
|
|
||||||
return struct.unpack("<d", buf.read(8))[0]
|
|
||||||
|
|
||||||
|
|
||||||
def _read_length(buf):
|
|
||||||
return struct.unpack("<I", buf.read(4))[0]
|
|
||||||
|
|
||||||
|
|
||||||
def read_string(buf):
|
|
||||||
is_empty = read_bool(buf)
|
|
||||||
if is_empty:
|
|
||||||
return ""
|
|
||||||
len_ = buf.read(1)[0]
|
|
||||||
if len_ == 0xFF:
|
|
||||||
len_ = _read_length(buf)
|
|
||||||
return buf.read(len_).decode("utf8")
|
|
||||||
|
|
||||||
|
|
||||||
def read_dictionary(buf):
|
|
||||||
len_ = _read_length(buf)
|
|
||||||
value = {}
|
|
||||||
for _ in range(len_):
|
|
||||||
key = read_string(buf)
|
|
||||||
value[key] = read(buf)
|
|
||||||
return value
|
|
||||||
|
|
||||||
|
|
||||||
def read_list(buf):
|
|
||||||
len_ = _read_length(buf)
|
|
||||||
value = []
|
|
||||||
for _ in range(len_):
|
|
||||||
read_string(buf)
|
|
||||||
value.append(read(buf))
|
|
||||||
return value
|
|
||||||
|
|
||||||
|
|
||||||
def read(buf):
|
|
||||||
type_, _any_type_flag = buf.read(2)
|
|
||||||
if type_ == 0:
|
|
||||||
return None
|
|
||||||
elif type_ == 1:
|
|
||||||
return read_bool(buf)
|
|
||||||
elif type_ == 2:
|
|
||||||
return read_number(buf)
|
|
||||||
elif type_ == 3:
|
|
||||||
return read_string(buf)
|
|
||||||
elif type_ == 4:
|
|
||||||
return read_list(buf)
|
|
||||||
elif type_ == 5:
|
|
||||||
return read_dictionary(buf)
|
|
||||||
else:
|
|
||||||
raise Exception("unknown property tree type 0x{:02x}".format(type_))
|
|
|
@ -8,7 +8,8 @@ import urllib.parse
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
|
||||||
sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "script-resources"))
|
sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "script-resources"))
|
||||||
import common_script_utils
|
|
||||||
|
import common_script_utils # noqa: E402
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_REGISTRY_DUMP_URL = "https://stronghold.crosscode.ru/~ccbot/emote-registry.json"
|
DEFAULT_REGISTRY_DUMP_URL = "https://stronghold.crosscode.ru/~ccbot/emote-registry.json"
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
# <https://wiki.factorio.com/Mod_settings_file_format>
|
|
||||||
# <https://forums.factorio.com/59851>
|
|
||||||
# <https://www.dropbox.com/sh/uscmj9y3cjfwpsr/AAD35_ZZu64EBi0awLA07fxga?dl=0>
|
|
||||||
# <https://github.com/credomane/factoriomodsettings/blob/master/src/FactorioModSettings.js>
|
|
||||||
|
|
||||||
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(
|
|
||||||
"<HHHH", f.read(8)
|
|
||||||
)
|
|
||||||
|
|
||||||
always_false_flag = factorio.property_tree.read_bool(f)
|
|
||||||
assert not always_false_flag
|
|
||||||
|
|
||||||
deserialized_data = {
|
|
||||||
"factorio_version": {
|
|
||||||
"main": version_main,
|
|
||||||
"major": version_major,
|
|
||||||
"minor": version_minor,
|
|
||||||
"developer": version_developer,
|
|
||||||
},
|
|
||||||
"data": factorio.property_tree.read(f),
|
|
||||||
}
|
|
||||||
|
|
||||||
print(json.dumps(deserialized_data, indent=2))
|
|
|
@ -17,7 +17,8 @@ import sqlite3
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "script-resources"))
|
sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "script-resources"))
|
||||||
import common_script_utils
|
|
||||||
|
import common_script_utils # noqa: E402
|
||||||
|
|
||||||
|
|
||||||
if sys.platform == "darwin":
|
if sys.platform == "darwin":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue