mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-08-08 22:36:48 +02:00
support json value in team.config field
This commit is contained in:
@ -1,11 +1,12 @@
|
|||||||
jc changelog
|
jc changelog
|
||||||
|
|
||||||
20250414 v1.25.5
|
20250503 v1.25.5
|
||||||
- Add `amixer` command parser
|
- Add `amixer` command parser
|
||||||
- Enhance `iptables` command parser to add default policy statistics fields
|
- Enhance `iptables` command parser to add default policy statistics fields
|
||||||
- Fix `bluetoothctl` parser failing to parse controllers with power state prop
|
- Fix `bluetoothctl` parser failing to parse controllers with power state prop
|
||||||
- Fix `lsblk` command parser to support multiple mountpoints. Also, added
|
- Fix `lsblk` command parser to support multiple mountpoints. Also, added
|
||||||
byte conversions for size fields.
|
byte conversions for size fields.
|
||||||
|
- Fix `nmcli` command parser to support `team.config` JSON field
|
||||||
- Fix `time` command parser for output that does not contain centiseconds
|
- Fix `time` command parser for output that does not contain centiseconds
|
||||||
- Fix `x509-cert` parser to handle IDNA2008 encoded email addresses with a warning
|
- Fix `x509-cert` parser to handle IDNA2008 encoded email addresses with a warning
|
||||||
- Fix typing for upcoming python v3.14
|
- Fix typing for upcoming python v3.14
|
||||||
|
@ -141,6 +141,7 @@ Examples:
|
|||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
|
import json
|
||||||
from typing import List, Dict, Optional
|
from typing import List, Dict, Optional
|
||||||
import jc.utils
|
import jc.utils
|
||||||
from jc.parsers.universal import sparse_table_parse
|
from jc.parsers.universal import sparse_table_parse
|
||||||
@ -149,7 +150,7 @@ from jc.exceptions import ParseError
|
|||||||
|
|
||||||
class info():
|
class info():
|
||||||
"""Provides parser metadata (version, author, etc.)"""
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
version = '1.0'
|
version = '1.1'
|
||||||
description = '`nmcli` command parser'
|
description = '`nmcli` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -313,8 +314,29 @@ def _device_show_parse(data: str) -> List[Dict]:
|
|||||||
def _connection_show_x_parse(data: str) -> List[Dict]:
|
def _connection_show_x_parse(data: str) -> List[Dict]:
|
||||||
raw_output: List = []
|
raw_output: List = []
|
||||||
item: Dict = {}
|
item: Dict = {}
|
||||||
|
in_team_config: bool = False
|
||||||
|
team_config_value: List = []
|
||||||
|
|
||||||
for line in filter(None, data.splitlines()):
|
for line in filter(None, data.splitlines()):
|
||||||
|
|
||||||
|
# fix for team.config, which is multi-line JSON
|
||||||
|
if line.startswith('team.config:'):
|
||||||
|
in_team_config = True
|
||||||
|
_, value = line.split(':', maxsplit=1)
|
||||||
|
team_config_value.append(value.strip())
|
||||||
|
item['team_config'] = []
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not line.startswith('team.') and in_team_config:
|
||||||
|
team_config_value.append(line.strip())
|
||||||
|
continue
|
||||||
|
|
||||||
|
in_team_config = False
|
||||||
|
|
||||||
|
if team_config_value:
|
||||||
|
item['team_config'] = json.loads(''.join(team_config_value))
|
||||||
|
team_config_value = []
|
||||||
|
|
||||||
key, value = line.split(':', maxsplit=1)
|
key, value = line.split(':', maxsplit=1)
|
||||||
|
|
||||||
key_n = _normalize_key(key)
|
key_n = _normalize_key(key)
|
||||||
|
Reference in New Issue
Block a user