From 7726af7dabdd3c8f844fb45a9a5dd24ebce03d94 Mon Sep 17 00:00:00 2001 From: xenofem Date: Mon, 11 Mar 2024 12:19:56 -0400 Subject: [PATCH] slightly more flexible detection of alphabetic numbering suffixes --- dlibrary/dlibrary.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dlibrary/dlibrary.py b/dlibrary/dlibrary.py index c246cc9..cf8b69b 100755 --- a/dlibrary/dlibrary.py +++ b/dlibrary/dlibrary.py @@ -606,10 +606,12 @@ def unique_hierarchical_prefix_numbering(entries, start_point=0): def alphabetic_numbering(entries, start_point): alphabetized = {} for entry in entries: - ending = nfc(entry.stem)[start_point:] + ending = nfc(entry.stem)[start_point:].strip(' -_()') if len(ending) > 1: return None index = 0 if ending == '' else ord(ending.lower()) - ord('a') + 1 + if index < 0 or index > 26: + return None if (index,) in alphabetized: return None alphabetized[(index,)] = [entry]