From 8fdb4b25fe02259307ff201f2de49ec8101c0d94 Mon Sep 17 00:00:00 2001 From: Joerg Schultze-Lutter Date: Sun, 12 Jun 2022 20:43:08 +0200 Subject: [PATCH] Bugfix make_pretty_dapnet_messages --- src/utils.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/utils.py b/src/utils.py index 4169558..e29f799 100644 --- a/src/utils.py +++ b/src/utils.py @@ -213,7 +213,7 @@ def make_pretty_dapnet_messages( # or a reference to a list item has not been specified at all # In this case, create an empty list if not destination_list: - destination_list = [""] + destination_list = [] # replace non-permitted APRS characters from the # message text @@ -253,16 +253,19 @@ def make_pretty_dapnet_messages( for msg in string_list: destination_list.append(msg) else: # try to insert - # Get very last element from list - string_from_list = destination_list[-1] - - # element + new string > max len? no: add to existing string, else create new element in list - if len(string_from_list) + len(message_to_add) + 1 <= max_len: - delimiter = "" - if len(string_from_list) > 0 and add_sep: - delimiter = separator_char - string_from_list = string_from_list + delimiter + message_to_add - destination_list[-1] = string_from_list + if len(destination_list) > 0: + # Get very last element from list + string_from_list = destination_list[-1] + + # element + new string > max len? no: add to existing string, else create new element in list + if len(string_from_list) + len(message_to_add) + 1 <= max_len: + delimiter = "" + if len(string_from_list) > 0 and add_sep: + delimiter = separator_char + string_from_list = string_from_list + delimiter + message_to_add + destination_list[-1] = string_from_list + else: + destination_list.append(message_to_add) else: destination_list.append(message_to_add)