Skip to content

Commit

Permalink
fix: [tabbasedhierarchy] fix issues with parsing remotectl_dumpstate
Browse files Browse the repository at this point in the history
  • Loading branch information
cvandeplas committed Nov 6, 2024
1 parent fdc7b23 commit 1b6f992
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/sysdiagnose/utils/tabbasedhierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def parse_tab_based_hierarchal_file(path: str) -> list | dict:


def parse_block(lines: list) -> list | dict:
result = {}
result = None
n = 0
while n < len(lines):
line = lines[n]
Expand Down Expand Up @@ -64,6 +64,8 @@ def parse_block(lines: list) -> list | dict:
if not result:
result = {}
result[key.strip()] = clean_value(value)
elif not key and isinstance(result, dict):
result[line.strip()] = ""
else:
if not result:
result = []
Expand Down
2 changes: 2 additions & 0 deletions tests/test_tabbasedhierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def test_remotectldumpstateblock(self):
' Properties: {',
' UsesRemoteXPC => true',
' }',
' foobar',
' ssh',
' Properties: {',
' Legacy => true',
Expand Down Expand Up @@ -84,6 +85,7 @@ def test_remotectldumpstateblock(self):
"UsesRemoteXPC": "true"
}
},
"foobar": "",
"ssh": {
"Properties": {
"Legacy": "true"
Expand Down

0 comments on commit 1b6f992

Please sign in to comment.