Skip to content

Commit 3646483

Browse files
committed
py_lua_helper: refactor some internal class fields
1 parent f9d33dd commit 3646483

1 file changed

Lines changed: 17 additions & 17 deletions

File tree

python_lua_helper/py_lua_helper.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ def __init__(
5454
self._temp_dir = temp_dir
5555
self._min_lua_version = min_lua_version or "5.1.0"
5656
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
57+
self._lua_binary = lua_binary
58+
self._lua_args = lua_args or []
59+
self._lua_actual_version = None
6060
# Validate required files exist
6161
if not os.path.exists(self._lua_config_script):
6262
raise FileNotFoundError(
@@ -69,7 +69,7 @@ def __init__(
6969
self._setup_temp_dir()
7070
try:
7171
# Detect Lua binary
72-
if not self.lua_binary:
72+
if not self._lua_binary:
7373
self._detect_lua_binary()
7474
# Execute the Lua loader
7575
self._run_lua_loader()
@@ -152,16 +152,16 @@ def _setup_temp_dir(self):
152152

153153
def _detect_lua_binary(self):
154154
"""Detect appropriate Lua binary based on version requirements."""
155-
if self.lua_binary:
155+
if self._lua_binary:
156156
# Use explicitly provided binary
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)
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)
161161
return
162162
else:
163163
raise ValueError(
164-
f"Lua binary does not meet version requirements: {self.lua_binary}"
164+
f"Lua binary does not meet version requirements: {self._lua_binary}"
165165
)
166166
# Probe for available Lua binaries
167167
lua_hints = [
@@ -183,7 +183,7 @@ def _detect_lua_binary(self):
183183
try:
184184
lua_path = shutil.which(f"{hint}{bin_suffix}")
185185
if lua_path and self._validate_lua_version(lua_path):
186-
self.lua_binary = os.path.abspath(lua_path)
186+
self._lua_binary = os.path.abspath(lua_path)
187187
return
188188
except Exception:
189189
continue
@@ -210,22 +210,22 @@ def _validate_lua_version(self, lua_binary: str) -> bool:
210210
if not (min_v <= act <= max_v):
211211
return False
212212
# Store the actual version if validation passes
213-
self.lua_actual_version = act_version
213+
self._lua_actual_version = act_version
214214
return True
215215
except Exception:
216216
return False
217217

218218
def _run_lua_loader(self):
219219
"""Execute the Lua loader script with appropriate parameters."""
220220
# Build command line arguments
221-
cmd = [self.lua_binary, os.path.join(os.path.dirname(__file__), "loader.lua")]
221+
cmd = [self._lua_binary, os.path.join(os.path.dirname(__file__), "loader.lua")]
222222
# Add version info
223223
cmd.extend(
224224
[
225225
"-ver",
226-
str(self.lua_actual_version[0]),
227-
str(self.lua_actual_version[1]),
228-
str(self.lua_actual_version[2]),
226+
str(self._lua_actual_version[0]),
227+
str(self._lua_actual_version[1]),
228+
str(self._lua_actual_version[2]),
229229
]
230230
)
231231
# Add configuration parameters
@@ -249,7 +249,7 @@ def _run_lua_loader(self):
249249
# Add -- separator
250250
cmd.append("--")
251251
# Add additional Lua arguments
252-
cmd.extend(self.lua_args)
252+
cmd.extend(self._lua_args)
253253
# Execute the command
254254
try:
255255
result = subprocess.run(cmd, capture_output=True, text=True, timeout=180)

0 commit comments

Comments
 (0)