mirror of
https://github.com/ruvnet/RuView.git
synced 2026-10-18 21:00:22 -05:00
fix(provision): avoid backslash in f-string expression (SyntaxError on Python <3.12)
Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
1 parent
bf46d113f3
commit
bf715c9cf0
1 file changed
+8
-2
@@ -141,6 +141,12 @@ _RESERVED_DEVICE_RE = re.compile(
|
||||
)
|
||||
|
||||
|
||||
def _unprefixed_state_name(port: str) -> str:
|
||||
"""Pre-reserved-name-fix state filename for `port` (no leading underscore)."""
|
||||
safe = port.replace("/", "_").replace(":", "_").replace("\\", "_")
|
||||
return f"{safe}.json"
|
||||
|
||||
|
||||
def _state_path_for(port: str, state_dir: str) -> str:
|
||||
"""File path for a given serial port. Sanitize the port for filesystem use."""
|
||||
safe = port.replace("/", "_").replace(":", "_").replace("\\", "_")
|
||||
@@ -314,7 +320,7 @@ def load_state(port: str, state_dir: str) -> dict:
|
||||
path = _state_path_for(port, state_dir)
|
||||
if not os.path.isfile(path):
|
||||
legacy = os.path.join(
|
||||
state_dir, f"{port.replace('/', '_').replace(':', '_').replace('\\', '_')}.json"
|
||||
state_dir, _unprefixed_state_name(port)
|
||||
)
|
||||
if legacy != path and os.path.isfile(legacy):
|
||||
path = legacy
|
||||
@@ -457,7 +463,7 @@ def load_board_state(port: str, mac, state_dir: str):
|
||||
if os.path.isfile(legacy):
|
||||
return load_state(port, state_dir), legacy
|
||||
unprefixed = os.path.join(
|
||||
state_dir, f"{port.replace('/', '_').replace(':', '_').replace('\\', '_')}.json"
|
||||
state_dir, _unprefixed_state_name(port)
|
||||
)
|
||||
if unprefixed != legacy and os.path.isfile(unprefixed):
|
||||
return load_state(port, state_dir), unprefixed
|
||||
|
||||
Reference in new issue
Block a user