Merge pull request #248 from pdxlocations:fix-protubuf-depend

Fix-protubuf-depend
This commit is contained in:
pdxlocations authored and GitHub committed 2026-03-02 16:31:55 -08:00
commit 773f43edd8
3 files changed
+21 -3

No files matched your search

+8 -1
View File
@@ -56,6 +56,13 @@ config_folder = os.path.abspath(config.node_configs_file_path)
# Load translations # Load translations
field_mapping, help_text = parse_ini_file(translation_file) field_mapping, help_text = parse_ini_file(translation_file)
def _is_repeated_field(field_desc) -> bool:
"""Return True if the protobuf field is repeated.
Protobuf 6.31.0 and later use an is_repeated property, while older versions compare against the label field.
"""
if hasattr(field_desc, "is_repeated"):
return bool(field_desc.is_repeated)
return field_desc.label == field_desc.LABEL_REPEATED
def reload_translations() -> None: def reload_translations() -> None:
global translation_file, field_mapping, help_text global translation_file, field_mapping, help_text
@@ -564,7 +571,7 @@ def settings_menu(stdscr: object, interface: object) -> None:
new_value = new_value == "True" or new_value is True new_value = new_value == "True" or new_value is True
menu_state.start_index.pop() menu_state.start_index.pop()
elif field.label == field.LABEL_REPEATED: # Handle repeated field - Not currently used elif _is_repeated_field(field): # Handle repeated field - Not currently used
new_value = get_repeated_input(current_value) new_value = get_repeated_input(current_value)
new_value = current_value if new_value is None else new_value.split(", ") new_value = current_value if new_value is None else new_value.split(", ")
menu_state.start_index.pop() menu_state.start_index.pop()
+12 -1
View File
@@ -9,6 +9,17 @@ from meshtastic.util import camel_to_snake, snake_to_camel, fromStr
# defs are from meshtastic/python/main # defs are from meshtastic/python/main
def _is_repeated_field(field_desc) -> bool:
"""Return True if the protobuf field is repeated.
Protobuf 6.31.0+ exposes `is_repeated`, while older versions require
checking `label == LABEL_REPEATED`.
"""
if hasattr(field_desc, "is_repeated"):
return bool(field_desc.is_repeated)
return field_desc.label == field_desc.LABEL_REPEATED
def traverseConfig(config_root, config, interface_config) -> bool: def traverseConfig(config_root, config, interface_config) -> bool:
"""Iterate through current config level preferences and either traverse deeper if preference is a dict or set preference""" """Iterate through current config level preferences and either traverse deeper if preference is a dict or set preference"""
snake_name = camel_to_snake(config_root) snake_name = camel_to_snake(config_root)
@@ -89,7 +100,7 @@ def setPref(config, comp_name, raw_val) -> bool:
return False return False
# repeating fields need to be handled with append, not setattr # repeating fields need to be handled with append, not setattr
if pref.label != pref.LABEL_REPEATED: if not _is_repeated_field(pref):
try: try:
if config_type.message_type is not None: if config_type.message_type is not None:
config_values = getattr(config_part, config_type.name) config_values = getattr(config_part, config_type.name)
+1 -1
View File
@@ -1,6 +1,6 @@
[project] [project]
name = "contact" name = "contact"
version = "1.4.16" version = "1.4.17"
description = "This Python curses client for Meshtastic is a terminal-based client designed to manage device settings, enable mesh chat communication, and handle configuration backups and restores." description = "This Python curses client for Meshtastic is a terminal-based client designed to manage device settings, enable mesh chat communication, and handle configuration backups and restores."
authors = [ authors = [
{name = "Ben Lipsey",email = "ben@pdxlocations.com"} {name = "Ben Lipsey",email = "ben@pdxlocations.com"}