Reorder group/server parsing and skip empty entries in config parser
This commit is contained in:
17
app/app.py
17
app/app.py
@@ -60,26 +60,29 @@ def parse_infrastructure_conf():
|
|||||||
stripped = line.strip()
|
stripped = line.strip()
|
||||||
if not stripped or stripped.startswith('#'):
|
if not stripped or stripped.startswith('#'):
|
||||||
continue
|
continue
|
||||||
# Group header: no leading whitespace
|
|
||||||
if line[0] not in (' ', '\t'):
|
# Server entry: starts with - or -- (with optional leading whitespace)
|
||||||
current_group = stripped
|
|
||||||
current_host = None
|
|
||||||
continue
|
|
||||||
# Detect prefix: -- child VM, - host
|
|
||||||
if stripped.startswith('--'):
|
if stripped.startswith('--'):
|
||||||
is_child = True
|
is_child = True
|
||||||
rest = stripped[2:].strip()
|
rest = stripped[2:].strip()
|
||||||
elif stripped.startswith('-'):
|
elif stripped.startswith('-'):
|
||||||
is_child = False
|
is_child = False
|
||||||
rest = stripped[1:].strip()
|
rest = stripped[1:].strip()
|
||||||
|
elif line[0] not in (' ', '\t') and not stripped.startswith('-'):
|
||||||
|
# Group header: no leading whitespace, no dash prefix
|
||||||
|
current_group = stripped
|
||||||
|
current_host = None
|
||||||
|
continue
|
||||||
else:
|
else:
|
||||||
# Legacy: no dash prefix, treat as host
|
# Legacy: indented without dash, treat as host
|
||||||
is_child = False
|
is_child = False
|
||||||
rest = stripped
|
rest = stripped
|
||||||
|
|
||||||
parts = rest.split(None, 1)
|
parts = rest.split(None, 1)
|
||||||
entry = parts[0] if parts else ''
|
entry = parts[0] if parts else ''
|
||||||
url = parts[1] if len(parts) > 1 else ''
|
url = parts[1] if len(parts) > 1 else ''
|
||||||
|
if not entry:
|
||||||
|
continue
|
||||||
if '@' in entry:
|
if '@' in entry:
|
||||||
user, host = entry.split('@', 1)
|
user, host = entry.split('@', 1)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user