Skip to content

Commit

Permalink
fix: [remotectl_dumpstate] fixes #114 parsing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
cvandeplas committed Nov 6, 2024
1 parent 74f0539 commit 84e9cd6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/sysdiagnose/utils/tabbasedhierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def parse_block(lines: list) -> list | dict:
n = 0
while n < len(lines):
line = lines[n]
if line.strip() == '}' or line.strip() == '':
if line.strip() == '}' or line.strip() == '' or line.strip() == ']':
n = n + 1
continue
# subsection if next line is more indented (more tabs at start of line)
Expand All @@ -26,7 +26,10 @@ def parse_block(lines: list) -> list | dict:
if next_depth > current_depth:
# subsection
# extract key
key = line.replace(':', '').replace('{', '').strip()
if '=>' in line:
key = line.split('=>')[0].strip()
else:
key = line.replace(':', '').replace('{', '').strip()
# identify end of subsection and call recursive parsing function with that block
extracted_block = []
while next_depth > current_depth:
Expand Down
10 changes: 9 additions & 1 deletion tests/test_tabbasedhierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def test_remotectldumpstateblock(self):
' Properties: {',
' AppleInternal => false',
' CPUArchitecture => x86_64h',
' EncryptedRemoteXPCPopulatedOIDs => [<capacity = 2>',
' 0: 1.2.840.113635.100.6.83',
' 1: 1.2.840.113635.100.6.84',
' ]',
' }',
' Services:',
' com.apple.osanalytics.logRelay',
Expand Down Expand Up @@ -68,7 +72,11 @@ def test_remotectldumpstateblock(self):
],
"Properties": {
"AppleInternal": "false",
"CPUArchitecture": "x86_64h"
"CPUArchitecture": "x86_64h",
"EncryptedRemoteXPCPopulatedOIDs": {
"0": "1.2.840.113635.100.6.83",
"1": "1.2.840.113635.100.6.84"
}
},
"Services": {
"com.apple.osanalytics.logRelay": {
Expand Down

0 comments on commit 84e9cd6

Please sign in to comment.