Python-Lua-Helper 1.2.0__tar.gz → 1.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_lua_helper-1.2.0 → python_lua_helper-1.4.0}/PKG-INFO +1 -1
- {python_lua_helper-1.2.0 → python_lua_helper-1.4.0}/hatch_build.py +1 -1
- {python_lua_helper-1.2.0 → python_lua_helper-1.4.0}/lua/build-mingw.sh +1 -1
- {python_lua_helper-1.2.0 → python_lua_helper-1.4.0}/lua/build.patch +16 -17
- python_lua_helper-1.4.0/lua/lua-5.5.0.sha256 +1 -0
- python_lua_helper-1.4.0/lua/lua-windows-i686 +0 -0
- python_lua_helper-1.4.0/lua/lua-windows-x86_64 +0 -0
- {python_lua_helper-1.2.0 → python_lua_helper-1.4.0}/python_lua_helper/loader.lua +29 -8
- {python_lua_helper-1.2.0 → python_lua_helper-1.4.0}/python_lua_helper/py_lua_helper.py +119 -108
- {python_lua_helper-1.2.0 → python_lua_helper-1.4.0}/python_lua_helper/test_example/example.cfg.lua +1 -1
- {python_lua_helper-1.2.0 → python_lua_helper-1.4.0}/python_lua_helper/test_example.py +1 -1
- python_lua_helper-1.2.0/lua/lua-5.4.8.sha256 +0 -1
- python_lua_helper-1.2.0/lua/lua-windows-i686 +0 -0
- python_lua_helper-1.2.0/lua/lua-windows-x86_64 +0 -0
- {python_lua_helper-1.2.0 → python_lua_helper-1.4.0}/.gitignore +0 -0
- {python_lua_helper-1.2.0 → python_lua_helper-1.4.0}/LICENSE +0 -0
- {python_lua_helper-1.2.0 → python_lua_helper-1.4.0}/pyproject.toml +0 -0
- {python_lua_helper-1.2.0 → python_lua_helper-1.4.0}/python_lua_helper/__init__.py +0 -0
- {python_lua_helper-1.2.0 → python_lua_helper-1.4.0}/python_lua_helper/test_example/example.post.lua +0 -0
- {python_lua_helper-1.2.0 → python_lua_helper-1.4.0}/python_lua_helper/test_example/example.pre.lua +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Python-Lua-Helper
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: Lua configuration system for your Python projects.
|
|
5
5
|
Project-URL: Repository, https://github.com/DarkCaster/Python-Lua-Helper.git
|
|
6
6
|
Author-email: DarkCaster <dark.caster@outlook.com>
|
|
@@ -57,7 +57,7 @@ class CustomBuildHook(BuildHookInterface):
|
|
|
57
57
|
arch = platform.machine().lower()
|
|
58
58
|
print(f"OS: {current_os}, arch: {arch}")
|
|
59
59
|
# Lua build defines
|
|
60
|
-
lua_version = "5.
|
|
60
|
+
lua_version = "5.5.0"
|
|
61
61
|
lua_src = f"lua-{lua_version}.tar.gz"
|
|
62
62
|
lua_checksum = f"lua-{lua_version}.sha256"
|
|
63
63
|
lua_patch = "build.patch"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
diff -uprN lua-5.
|
|
2
|
-
--- lua-5.
|
|
3
|
-
+++ lua-5.
|
|
4
|
-
@@ -53,
|
|
1
|
+
diff -uprN lua-5.5.0.old/src/luaconf.h lua-5.5.0/src/luaconf.h
|
|
2
|
+
--- lua-5.5.0.old/src/luaconf.h 2025-12-15 13:44:40.000000000 +0300
|
|
3
|
+
+++ lua-5.5.0/src/luaconf.h 2026-02-08 02:46:07.116399878 +0300
|
|
4
|
+
@@ -53,7 +53,6 @@
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
#if defined(LUA_USE_WINDOWS)
|
|
@@ -9,16 +9,19 @@ diff -uprN lua-5.4.8.old/src/luaconf.h lua-5.4.8/src/luaconf.h
|
|
|
9
9
|
#define LUA_USE_C89 /* broadly, Windows is C89 */
|
|
10
10
|
#endif
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
@@ -69,21 +68,18 @@
|
|
13
|
+
*/
|
|
13
14
|
#if defined(LUA_USE_LINUX)
|
|
14
15
|
#define LUA_USE_POSIX
|
|
15
16
|
-#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
|
|
17
|
+
#define LUA_READLINELIB "libreadline.so"
|
|
16
18
|
#endif
|
|
17
19
|
|
|
18
20
|
|
|
19
21
|
#if defined(LUA_USE_MACOSX)
|
|
20
22
|
#define LUA_USE_POSIX
|
|
21
|
-
-#define LUA_USE_DLOPEN /*
|
|
23
|
+
-#define LUA_USE_DLOPEN /* macOS does not need -ldl */
|
|
24
|
+
#define LUA_READLINELIB "libedit.dylib"
|
|
22
25
|
#endif
|
|
23
26
|
|
|
24
27
|
|
|
@@ -28,25 +31,21 @@ diff -uprN lua-5.4.8.old/src/luaconf.h lua-5.4.8/src/luaconf.h
|
|
|
28
31
|
#endif
|
|
29
32
|
|
|
30
33
|
|
|
31
|
-
diff -uprN lua-5.
|
|
32
|
-
--- lua-5.
|
|
33
|
-
+++ lua-5.
|
|
34
|
-
@@ -
|
|
35
|
-
|
|
34
|
+
diff -uprN lua-5.5.0.old/src/Makefile lua-5.5.0/src/Makefile
|
|
35
|
+
--- lua-5.5.0.old/src/Makefile 2025-07-07 03:19:14.000000000 +0300
|
|
36
|
+
+++ lua-5.5.0/src/Makefile 2026-02-08 02:51:17.686297782 +0300
|
|
37
|
+
@@ -121,15 +121,14 @@ ios:
|
|
38
|
+
$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_IOS"
|
|
36
39
|
|
|
37
|
-
linux
|
|
40
|
+
Linux linux:
|
|
38
41
|
- $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl"
|
|
39
42
|
+ $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS=""
|
|
40
43
|
|
|
41
|
-
linux-readline:
|
|
42
|
-
- $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX -DLUA_USE_READLINE" SYSLIBS="-Wl,-E -ldl -lreadline"
|
|
43
|
-
+ $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX -DLUA_USE_READLINE" SYSLIBS="-Wl,-E -lreadline"
|
|
44
|
-
|
|
45
44
|
Darwin macos macosx:
|
|
46
45
|
$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_MACOSX -DLUA_USE_READLINE" SYSLIBS="-lreadline"
|
|
47
46
|
|
|
48
47
|
mingw:
|
|
49
|
-
- $(MAKE) "LUA_A=
|
|
48
|
+
- $(MAKE) "LUA_A=lua55.dll" "LUA_T=lua.exe" \
|
|
50
49
|
- "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \
|
|
51
50
|
- "SYSCFLAGS=-DLUA_BUILD_AS_DLL" "SYSLIBS=" "SYSLDFLAGS=-s" lua.exe
|
|
52
51
|
+ $(MAKE) "LUA_T=lua.exe" \
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
57ccc32bbbd005cab75bcc52444052535af691789dba2b9016d5c50640d68b3d *lua-5.5.0.tar.gz
|
|
Binary file
|
|
Binary file
|
|
@@ -242,19 +242,36 @@ if loader.postexec ~= nil then
|
|
|
242
242
|
dofile(loader.postexec)
|
|
243
243
|
end
|
|
244
244
|
|
|
245
|
-
loader.dataout=loader.tmpdir..loader.pathseparator.."data"
|
|
246
|
-
loader.metaout=loader.tmpdir..loader.pathseparator.."meta"
|
|
245
|
+
loader.dataout=loader.tmpdir..loader.pathseparator.."data.tmp"
|
|
246
|
+
loader.metaout=loader.tmpdir..loader.pathseparator.."meta.tmp"
|
|
247
|
+
loader.indexout=loader.tmpdir..loader.pathseparator.."index.tmp"
|
|
248
|
+
|
|
249
|
+
target_data = assert(io.open(loader.dataout, "w"))
|
|
250
|
+
target_meta = assert(io.open(loader.metaout, "w"))
|
|
251
|
+
target_index = assert(io.open(loader.indexout, "w"))
|
|
252
|
+
|
|
253
|
+
target_data:write("start")
|
|
254
|
+
target_data:write("\255".."\000")
|
|
255
|
+
|
|
256
|
+
target_meta:write("start")
|
|
257
|
+
target_meta:write("\255".."\000")
|
|
258
|
+
|
|
259
|
+
target_index:write("start")
|
|
260
|
+
target_index:write("\255".."\000")
|
|
247
261
|
|
|
248
262
|
function loader_data_export(name,value)
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
263
|
+
-- write value to target_data
|
|
264
|
+
target_data:write(string.format("%s",tostring(value)))
|
|
265
|
+
target_data:write("\255".."\000")
|
|
252
266
|
end
|
|
253
267
|
|
|
254
268
|
function loader_meta_export(name,value)
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
269
|
+
-- write name to target_index
|
|
270
|
+
target_index:write(name)
|
|
271
|
+
target_index:write("\255".."\000")
|
|
272
|
+
-- write value to target_meta
|
|
273
|
+
target_meta:write(string.format("%s",tostring(value)))
|
|
274
|
+
target_meta:write("\255".."\000")
|
|
258
275
|
end
|
|
259
276
|
|
|
260
277
|
function loader_node_export(name,node)
|
|
@@ -309,3 +326,7 @@ for index,value in ipairs(loader.export) do
|
|
|
309
326
|
loader_node_export(value,target)
|
|
310
327
|
end
|
|
311
328
|
end
|
|
329
|
+
|
|
330
|
+
target_index:close()
|
|
331
|
+
target_meta:close()
|
|
332
|
+
target_data:close()
|
|
@@ -45,53 +45,47 @@ class PyLuaHelper:
|
|
|
45
45
|
lua_binary: Path to specific Lua binary (optional, will be auto-detected if not provided)
|
|
46
46
|
lua_args: Additional arguments to pass to Lua script (will be placed to loader.args)
|
|
47
47
|
"""
|
|
48
|
-
self.
|
|
49
|
-
self.
|
|
50
|
-
self.
|
|
51
|
-
self.
|
|
52
|
-
self.
|
|
53
|
-
self.
|
|
54
|
-
self.
|
|
55
|
-
self.
|
|
56
|
-
self.
|
|
57
|
-
self.
|
|
58
|
-
self.
|
|
59
|
-
self.
|
|
60
|
-
|
|
48
|
+
self._lua_config_script = os.path.abspath(lua_config_script)
|
|
49
|
+
self._export_vars = export_vars or []
|
|
50
|
+
self._pre_script = pre_script
|
|
51
|
+
self._post_script = post_script
|
|
52
|
+
self._extra_strings = extra_strings or []
|
|
53
|
+
self._work_dir = work_dir or os.path.dirname(self._lua_config_script)
|
|
54
|
+
self._temp_dir = temp_dir
|
|
55
|
+
self._min_lua_version = min_lua_version or "5.1.0"
|
|
56
|
+
self._max_lua_version = max_lua_version or "5.5.999"
|
|
57
|
+
self._lua_binary = lua_binary
|
|
58
|
+
self._lua_args = lua_args or []
|
|
59
|
+
self._lua_actual_version = None
|
|
61
60
|
# Validate required files exist
|
|
62
|
-
if not os.path.exists(self.
|
|
61
|
+
if not os.path.exists(self._lua_config_script):
|
|
63
62
|
raise FileNotFoundError(
|
|
64
|
-
f"Main config file not found: {self.
|
|
63
|
+
f"Main config file not found: {self._lua_config_script}"
|
|
65
64
|
)
|
|
66
|
-
|
|
67
65
|
# Initialize internal state
|
|
68
66
|
self._variables: Dict[str, str] = {}
|
|
69
67
|
self._metadata: Dict[str, str] = {}
|
|
70
|
-
self._export_list: List[str] = []
|
|
71
|
-
|
|
72
68
|
# Initialize temporary directory
|
|
73
69
|
self._setup_temp_dir()
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
# Clean up temp directory
|
|
86
|
-
self._cleanup()
|
|
70
|
+
try:
|
|
71
|
+
# Detect Lua binary
|
|
72
|
+
if not self._lua_binary:
|
|
73
|
+
self._detect_lua_binary()
|
|
74
|
+
# Execute the Lua loader
|
|
75
|
+
self._run_lua_loader()
|
|
76
|
+
# Parse results
|
|
77
|
+
self._parse_results()
|
|
78
|
+
finally:
|
|
79
|
+
# Clean up temp directory
|
|
80
|
+
self._cleanup()
|
|
87
81
|
|
|
88
82
|
def _setup_temp_dir(self):
|
|
89
83
|
"""Setup temporary directory for storing exported variables."""
|
|
90
|
-
if self.
|
|
91
|
-
if not os.path.exists(self.
|
|
92
|
-
raise ValueError(f"Temp directory does not exist: {self.
|
|
93
|
-
self.
|
|
94
|
-
self.
|
|
84
|
+
if self._temp_dir:
|
|
85
|
+
if not os.path.exists(self._temp_dir):
|
|
86
|
+
raise ValueError(f"Temp directory does not exist: {self._temp_dir}")
|
|
87
|
+
self._temp_dir = os.path.abspath(self._temp_dir)
|
|
88
|
+
self._temp_dir = tempfile.mkdtemp(prefix="lua-helper-", dir=self._temp_dir)
|
|
95
89
|
else:
|
|
96
90
|
# Detect temp directory if not provided, platform dependent
|
|
97
91
|
if os.name == "nt": # Windows
|
|
@@ -109,7 +103,7 @@ class PyLuaHelper:
|
|
|
109
103
|
for base_dir in temp_dirs:
|
|
110
104
|
try:
|
|
111
105
|
# Try to create temp directory in this location
|
|
112
|
-
self.
|
|
106
|
+
self._temp_dir = tempfile.mkdtemp(
|
|
113
107
|
prefix="lua-helper-", dir=base_dir
|
|
114
108
|
)
|
|
115
109
|
break
|
|
@@ -141,34 +135,33 @@ class PyLuaHelper:
|
|
|
141
135
|
text=True,
|
|
142
136
|
)
|
|
143
137
|
if result.returncode == 0:
|
|
144
|
-
self.
|
|
138
|
+
self._temp_dir = target
|
|
145
139
|
break
|
|
146
140
|
except Exception:
|
|
147
141
|
continue
|
|
148
|
-
if not self.
|
|
149
|
-
self.
|
|
142
|
+
if not self._temp_dir:
|
|
143
|
+
self._temp_dir = "/tmp"
|
|
150
144
|
# Create unique temp directory
|
|
151
|
-
self.
|
|
152
|
-
prefix="lua-helper-", dir=self.
|
|
145
|
+
self._temp_dir = tempfile.mkdtemp(
|
|
146
|
+
prefix="lua-helper-", dir=self._temp_dir
|
|
153
147
|
)
|
|
154
|
-
#
|
|
155
|
-
self.
|
|
156
|
-
self.
|
|
157
|
-
os.
|
|
158
|
-
os.makedirs(self.data_dir)
|
|
148
|
+
# Define temp files for data exchange
|
|
149
|
+
self._meta_file = os.path.join(self._temp_dir, "meta.tmp")
|
|
150
|
+
self._data_file = os.path.join(self._temp_dir, "data.tmp")
|
|
151
|
+
self._index_file = os.path.join(self._temp_dir, "index.tmp")
|
|
159
152
|
|
|
160
153
|
def _detect_lua_binary(self):
|
|
161
154
|
"""Detect appropriate Lua binary based on version requirements."""
|
|
162
|
-
if self.
|
|
155
|
+
if self._lua_binary:
|
|
163
156
|
# Use explicitly provided binary
|
|
164
|
-
if not os.path.exists(self.
|
|
165
|
-
raise FileNotFoundError(f"Lua binary not found: {self.
|
|
166
|
-
if self._validate_lua_version(self.
|
|
167
|
-
self.
|
|
157
|
+
if not os.path.exists(self._lua_binary):
|
|
158
|
+
raise FileNotFoundError(f"Lua binary not found: {self._lua_binary}")
|
|
159
|
+
if self._validate_lua_version(self._lua_binary):
|
|
160
|
+
self._lua_binary = os.path.abspath(self._lua_binary)
|
|
168
161
|
return
|
|
169
162
|
else:
|
|
170
163
|
raise ValueError(
|
|
171
|
-
f"Lua binary does not meet version requirements: {self.
|
|
164
|
+
f"Lua binary does not meet version requirements: {self._lua_binary}"
|
|
172
165
|
)
|
|
173
166
|
# Probe for available Lua binaries
|
|
174
167
|
lua_hints = [
|
|
@@ -190,7 +183,7 @@ class PyLuaHelper:
|
|
|
190
183
|
try:
|
|
191
184
|
lua_path = shutil.which(f"{hint}{bin_suffix}")
|
|
192
185
|
if lua_path and self._validate_lua_version(lua_path):
|
|
193
|
-
self.
|
|
186
|
+
self._lua_binary = os.path.abspath(lua_path)
|
|
194
187
|
return
|
|
195
188
|
except Exception:
|
|
196
189
|
continue
|
|
@@ -207,20 +200,17 @@ class PyLuaHelper:
|
|
|
207
200
|
)
|
|
208
201
|
if not version_match:
|
|
209
202
|
return False
|
|
210
|
-
|
|
211
203
|
act_version = [int(x) for x in version_match.groups()]
|
|
212
|
-
min_version = [int(x) for x in self.
|
|
213
|
-
max_version = [int(x) for x in self.
|
|
214
|
-
|
|
204
|
+
min_version = [int(x) for x in self._min_lua_version.split(".")]
|
|
205
|
+
max_version = [int(x) for x in self._max_lua_version.split(".")]
|
|
215
206
|
# Check version range
|
|
216
207
|
for i, (act, min_v, max_v) in enumerate(
|
|
217
208
|
zip(act_version, min_version, max_version)
|
|
218
209
|
):
|
|
219
210
|
if not (min_v <= act <= max_v):
|
|
220
211
|
return False
|
|
221
|
-
|
|
222
212
|
# Store the actual version if validation passes
|
|
223
|
-
self.
|
|
213
|
+
self._lua_actual_version = act_version
|
|
224
214
|
return True
|
|
225
215
|
except Exception:
|
|
226
216
|
return False
|
|
@@ -228,49 +218,38 @@ class PyLuaHelper:
|
|
|
228
218
|
def _run_lua_loader(self):
|
|
229
219
|
"""Execute the Lua loader script with appropriate parameters."""
|
|
230
220
|
# Build command line arguments
|
|
231
|
-
cmd = [self.
|
|
232
|
-
|
|
221
|
+
cmd = [self._lua_binary, os.path.join(os.path.dirname(__file__), "loader.lua")]
|
|
233
222
|
# Add version info
|
|
234
223
|
cmd.extend(
|
|
235
224
|
[
|
|
236
225
|
"-ver",
|
|
237
|
-
str(self.
|
|
238
|
-
str(self.
|
|
239
|
-
str(self.
|
|
226
|
+
str(self._lua_actual_version[0]),
|
|
227
|
+
str(self._lua_actual_version[1]),
|
|
228
|
+
str(self._lua_actual_version[2]),
|
|
240
229
|
]
|
|
241
230
|
)
|
|
242
|
-
|
|
243
231
|
# Add configuration parameters
|
|
244
|
-
cmd.extend(["-c", self.
|
|
245
|
-
|
|
232
|
+
cmd.extend(["-c", self._lua_config_script])
|
|
246
233
|
# Add export variables
|
|
247
|
-
for var in self.
|
|
234
|
+
for var in self._export_vars:
|
|
248
235
|
cmd.extend(["-e", var])
|
|
249
|
-
|
|
250
236
|
# Add pre script
|
|
251
|
-
if self.
|
|
252
|
-
cmd.extend(["-pre", self.
|
|
253
|
-
|
|
237
|
+
if self._pre_script:
|
|
238
|
+
cmd.extend(["-pre", self._pre_script])
|
|
254
239
|
# Add post script
|
|
255
|
-
if self.
|
|
256
|
-
cmd.extend(["-post", self.
|
|
257
|
-
|
|
240
|
+
if self._post_script:
|
|
241
|
+
cmd.extend(["-post", self._post_script])
|
|
258
242
|
# Add extra strings
|
|
259
|
-
for extra in self.
|
|
243
|
+
for extra in self._extra_strings:
|
|
260
244
|
cmd.extend(["-ext", extra])
|
|
261
|
-
|
|
262
245
|
# Add work directory
|
|
263
|
-
cmd.extend(["-w", self.
|
|
264
|
-
|
|
246
|
+
cmd.extend(["-w", self._work_dir])
|
|
265
247
|
# Add temp directory
|
|
266
|
-
cmd.extend(["-t", self.
|
|
267
|
-
|
|
248
|
+
cmd.extend(["-t", self._temp_dir])
|
|
268
249
|
# Add -- separator
|
|
269
250
|
cmd.append("--")
|
|
270
|
-
|
|
271
251
|
# Add additional Lua arguments
|
|
272
|
-
cmd.extend(self.
|
|
273
|
-
|
|
252
|
+
cmd.extend(self._lua_args)
|
|
274
253
|
# Execute the command
|
|
275
254
|
try:
|
|
276
255
|
result = subprocess.run(cmd, capture_output=True, text=True, timeout=180)
|
|
@@ -283,34 +262,61 @@ class PyLuaHelper:
|
|
|
283
262
|
except subprocess.TimeoutExpired:
|
|
284
263
|
raise RuntimeError("Lua loader timed out")
|
|
285
264
|
|
|
286
|
-
def
|
|
287
|
-
"""
|
|
288
|
-
|
|
289
|
-
try:
|
|
290
|
-
self._export_list = os.listdir(self.data_dir)
|
|
291
|
-
except Exception:
|
|
292
|
-
self._export_list = []
|
|
265
|
+
def _parse_text_fields(self, file_path: str):
|
|
266
|
+
"""
|
|
267
|
+
Parses a binary file containing UTF-8 text fields generated by loader.lua
|
|
293
268
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
269
|
+
Args:
|
|
270
|
+
file_path (str): The path to the binary file.
|
|
271
|
+
|
|
272
|
+
Returns:
|
|
273
|
+
list: A list of strings containing the parsed UTF-8 fields.
|
|
274
|
+
"""
|
|
275
|
+
fields = []
|
|
276
|
+
with open(file_path, "rb") as f:
|
|
277
|
+
file_content = f.read()
|
|
278
|
+
# Locate the start marker, set initial position
|
|
279
|
+
header_marker = b"start\xff\x00"
|
|
280
|
+
start_pos = file_content.find(header_marker)
|
|
281
|
+
if start_pos == -1:
|
|
282
|
+
raise ValueError(f"Failed to locate start marker at {file_path}")
|
|
283
|
+
current_pos = start_pos + len(header_marker)
|
|
284
|
+
# Read UTF8 text fields, separated with special sequence
|
|
285
|
+
separator = b"\xff\x00"
|
|
286
|
+
while True:
|
|
287
|
+
# Find the next separator
|
|
288
|
+
sep_pos = file_content.find(separator, current_pos)
|
|
289
|
+
if sep_pos != -1:
|
|
290
|
+
# Extract the bytes for the current field
|
|
291
|
+
field_bytes = file_content[current_pos:sep_pos]
|
|
292
|
+
field_str = field_bytes.decode("utf-8")
|
|
293
|
+
fields.append(field_str)
|
|
294
|
+
# Move pointer past the separator
|
|
295
|
+
current_pos = sep_pos + len(separator)
|
|
296
|
+
else:
|
|
297
|
+
# No separator found, this is the last field (no terminator at the end)
|
|
298
|
+
if current_pos < len(file_content):
|
|
299
|
+
raise ValueError(
|
|
300
|
+
f"Surplus data at the end of file, at pos: {current_pos}"
|
|
301
301
|
)
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
302
|
+
break
|
|
303
|
+
return fields
|
|
304
|
+
|
|
305
|
+
def _parse_results(self):
|
|
306
|
+
"""Parse exported variables from temporary files."""
|
|
307
|
+
# Read exported data
|
|
308
|
+
exports = self._parse_text_fields(self._index_file)
|
|
309
|
+
meta = self._parse_text_fields(self._meta_file)
|
|
310
|
+
data = self._parse_text_fields(self._data_file)
|
|
311
|
+
for index, value in enumerate(exports):
|
|
312
|
+
self._variables[value] = data[index]
|
|
313
|
+
self._metadata[value] = meta[index]
|
|
308
314
|
|
|
309
315
|
def _cleanup(self):
|
|
310
316
|
"""Clean up temporary directory."""
|
|
311
|
-
if self.
|
|
317
|
+
if self._temp_dir and os.path.exists(self._temp_dir):
|
|
312
318
|
try:
|
|
313
|
-
shutil.rmtree(self.
|
|
319
|
+
shutil.rmtree(self._temp_dir)
|
|
314
320
|
except Exception:
|
|
315
321
|
pass
|
|
316
322
|
|
|
@@ -394,7 +400,12 @@ class PyLuaHelper:
|
|
|
394
400
|
try:
|
|
395
401
|
value_type = self.get_type(key)
|
|
396
402
|
if value_type == "boolean":
|
|
397
|
-
|
|
403
|
+
value = self._variables.get(key)
|
|
404
|
+
if value == "true":
|
|
405
|
+
value = True
|
|
406
|
+
elif value == "false":
|
|
407
|
+
value = False
|
|
408
|
+
return bool(value)
|
|
398
409
|
raise ValueError(f"Invalid value type: {value_type}")
|
|
399
410
|
except ValueError:
|
|
400
411
|
if default is not None:
|
|
@@ -147,7 +147,7 @@ print(f"example.py: {cfg.get_list('config.sub.loader_args')}")
|
|
|
147
147
|
# Test typed get
|
|
148
148
|
print("example.py: === test getting values with specific type from config.sub.types table ===")
|
|
149
149
|
print(f"example.py: get bool value, no fallback: cfg['config.sub.types.b'] = {cfg.get_bool('config.sub.types.b')}")
|
|
150
|
-
print(f"example.py: get missing bool value, fallback: cfg['config.sub.types.b1'] = {cfg.get_bool('config.sub.types.b1',
|
|
150
|
+
print(f"example.py: get missing bool value, fallback: cfg['config.sub.types.b1'] = {cfg.get_bool('config.sub.types.b1', True)}")
|
|
151
151
|
print(f"example.py: get bool value from int, fallback: cfg['config.sub.types.i'] = {cfg.get_bool('config.sub.types.i', False)}")
|
|
152
152
|
|
|
153
153
|
print(f"example.py: get int value, no fallback: cfg['config.sub.types.i'] = {cfg.get_int('config.sub.types.i')}")
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
4f18ddae154e793e46eeab727c59ef1c0c0c2b744e7b94219710d76f530629ae *lua-5.4.8.tar.gz
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_lua_helper-1.2.0 → python_lua_helper-1.4.0}/python_lua_helper/test_example/example.post.lua
RENAMED
|
File without changes
|
{python_lua_helper-1.2.0 → python_lua_helper-1.4.0}/python_lua_helper/test_example/example.pre.lua
RENAMED
|
File without changes
|