Skip to content

Commit 222d1b7

Browse files
support json value in team.config field
1 parent 34fda09 commit 222d1b7

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

CHANGELOG

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
jc changelog
22

3-
20250414 v1.25.5
3+
20250503 v1.25.5
44
- Add `amixer` command parser
55
- Enhance `iptables` command parser to add default policy statistics fields
66
- Fix `bluetoothctl` parser failing to parse controllers with power state prop
77
- Fix `lsblk` command parser to support multiple mountpoints. Also, added
88
byte conversions for size fields.
9+
- Fix `nmcli` command parser to support `team.config` JSON field
910
- Fix `time` command parser for output that does not contain centiseconds
1011
- Fix `x509-cert` parser to handle IDNA2008 encoded email addresses with a warning
1112
- Fix typing for upcoming python v3.14

jc/parsers/nmcli.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141
]
142142
"""
143143
import re
144+
import json
144145
from typing import List, Dict, Optional
145146
import jc.utils
146147
from jc.parsers.universal import sparse_table_parse
@@ -149,7 +150,7 @@
149150

150151
class info():
151152
"""Provides parser metadata (version, author, etc.)"""
152-
version = '1.0'
153+
version = '1.1'
153154
description = '`nmcli` command parser'
154155
author = 'Kelly Brazil'
155156
author_email = 'kellyjonbrazil@gmail.com'
@@ -313,8 +314,29 @@ def _device_show_parse(data: str) -> List[Dict]:
313314
def _connection_show_x_parse(data: str) -> List[Dict]:
314315
raw_output: List = []
315316
item: Dict = {}
317+
in_team_config: bool = False
318+
team_config_value: List = []
316319

317320
for line in filter(None, data.splitlines()):
321+
322+
# fix for team.config, which is multi-line JSON
323+
if line.startswith('team.config:'):
324+
in_team_config = True
325+
_, value = line.split(':', maxsplit=1)
326+
team_config_value.append(value.strip())
327+
item['team_config'] = []
328+
continue
329+
330+
if not line.startswith('team.') and in_team_config:
331+
team_config_value.append(line.strip())
332+
continue
333+
334+
in_team_config = False
335+
336+
if team_config_value:
337+
item['team_config'] = json.loads(''.join(team_config_value))
338+
team_config_value = []
339+
318340
key, value = line.split(':', maxsplit=1)
319341

320342
key_n = _normalize_key(key)

0 commit comments

Comments
 (0)