From ae56fe5175ab13c8d5f456215759ae1157eb420a Mon Sep 17 00:00:00 2001 From: xenofem Date: Fri, 29 Mar 2024 14:29:35 -0400 Subject: [PATCH] handle edge case of prefix detection --- dlibrary/dlibrary.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dlibrary/dlibrary.py b/dlibrary/dlibrary.py index d0c17dc..14adba3 100755 --- a/dlibrary/dlibrary.py +++ b/dlibrary/dlibrary.py @@ -816,7 +816,10 @@ def unique_hierarchical_prefix_numbering(entries, start_point=0): ents_idx = numbering.pop(idx) debug(f'Index {idx} has multiple entries') longest = max(ents_idx, key=lambda e: len(nname(e))) - next_layer_start = pos + NUMBER_REGEX.match(nname(longest)[pos:]).end() + next_match = NUMBER_REGEX.match(nname(longest)[pos:]) + if not next_match: + return None + next_layer_start = pos + next_match.end() sub_numbering = unique_hierarchical_prefix_numbering(ents_idx, start_point=next_layer_start) or alphabetic_numbering(ents_idx, next_layer_start) if not sub_numbering: return None