handle alphabetic suffixes
This commit is contained in:
parent
330b10c85b
commit
657ec65e4a
|
@ -264,7 +264,7 @@ def unique_hierarchical_prefix_numbering(entries, start_point=0):
|
||||||
if len(numbering[idx]) > 1:
|
if len(numbering[idx]) > 1:
|
||||||
ents_idx = numbering.pop(idx)
|
ents_idx = numbering.pop(idx)
|
||||||
next_layer_start = pos + NUMBER_REGEX.match(ents_idx[0].name[pos:]).end()
|
next_layer_start = pos + NUMBER_REGEX.match(ents_idx[0].name[pos:]).end()
|
||||||
sub_numbering = unique_hierarchical_prefix_numbering(ents_idx, start_point=next_layer_start)
|
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:
|
if not sub_numbering:
|
||||||
return None
|
return None
|
||||||
for sub_idx in sub_numbering:
|
for sub_idx in sub_numbering:
|
||||||
|
@ -274,6 +274,22 @@ def unique_hierarchical_prefix_numbering(entries, start_point=0):
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def alphabetic_numbering(entries, start_point):
|
||||||
|
alphabetized = {}
|
||||||
|
for entry in entries:
|
||||||
|
ending = entry.stem[start_point:]
|
||||||
|
if len(ending) > 1:
|
||||||
|
return None
|
||||||
|
index = 0 if ending == '' else ord(ending.lower()) - ord('a')
|
||||||
|
if index in alphabetized:
|
||||||
|
return None
|
||||||
|
alphabetized[(index,)] = [entry]
|
||||||
|
indices = list(alphabetized.keys())
|
||||||
|
indices.sort()
|
||||||
|
if indices != [(i,) for i in range(len(indices))]:
|
||||||
|
return None
|
||||||
|
return alphabetized
|
||||||
|
|
||||||
def link_ordered_files(ordering, dest, start_index):
|
def link_ordered_files(ordering, dest, start_index):
|
||||||
dest.mkdir(parents=True, exist_ok=True)
|
dest.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue