mirror of
https://github.com/meshtastic/python.git
synced 2026-04-17 13:31:43 -04:00
Fix property fallback
This commit is contained in:
@@ -158,12 +158,11 @@ def getPref(node, comp_name) -> bool:
|
||||
config_values = getattr(config, config_type.name)
|
||||
if not wholeField:
|
||||
pref_value = getattr(config_values, pref.name)
|
||||
repeated = getattr(pref, "is_repeated", pref.label == pref.LABEL_REPEATED)
|
||||
repeated = _is_repeated_field(pref)
|
||||
_printSetting(config_type, uni_name, pref_value, repeated)
|
||||
else:
|
||||
for field in config_values.ListFields():
|
||||
fd = field[0]
|
||||
repeated = getattr(fd, "is_repeated", fd.label == fd.LABEL_REPEATED)
|
||||
repeated = _is_repeated_field(field[0])
|
||||
_printSetting(config_type, field[0].name, field[1], repeated)
|
||||
else:
|
||||
# Always show whole field for remote node
|
||||
@@ -254,7 +253,7 @@ def setPref(config, comp_name, raw_val) -> bool:
|
||||
return False
|
||||
|
||||
# repeating fields need to be handled with append, not setattr
|
||||
if not getattr(pref, "is_repeated", pref.label == pref.LABEL_REPEATED):
|
||||
if not _is_repeated_field(pref):
|
||||
try:
|
||||
if config_type.message_type is not None:
|
||||
config_values = getattr(config_part, config_type.name)
|
||||
@@ -1132,6 +1131,12 @@ def subscribe() -> None:
|
||||
|
||||
# pub.subscribe(onNode, "meshtastic.node")
|
||||
|
||||
def _is_repeated_field(field_desc) -> bool:
|
||||
"""Return True if the protobuf field is repeated. Protobuf 6:3.10 and later us an is_repeated property"""
|
||||
if hasattr(field_desc, "is_repeated"):
|
||||
return bool(field_desc.is_repeated)
|
||||
return field_desc.label == field_desc.LABEL_REPEATED
|
||||
|
||||
def set_missing_flags_false(config_dict: dict, true_defaults: set[tuple[str, str]]) -> None:
|
||||
"""Ensure that missing default=True keys are present in the config_dict and set to False."""
|
||||
for path in true_defaults:
|
||||
|
||||
Reference in New Issue
Block a user