Skip to content

Commit 8f197ea

Browse files
feat: Create longest and shortest path criteria (#1242)
* Create longest and shortest path criteria
1 parent 3a97ba9 commit 8f197ea

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

core/prioritize.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,17 @@ class FilenameCategory(CriterionCategory):
9696
DOESNT_END_WITH_NUMBER = 1
9797
LONGEST = 2
9898
SHORTEST = 3
99+
LONGEST_PATH = 4
100+
SHORTEST_PATH = 5
99101

100102
def format_criterion_value(self, value):
101103
return {
102104
self.ENDS_WITH_NUMBER: tr("Ends with number"),
103105
self.DOESNT_END_WITH_NUMBER: tr("Doesn't end with number"),
104106
self.LONGEST: tr("Longest"),
105107
self.SHORTEST: tr("Shortest"),
108+
self.LONGEST_PATH: tr("Longest Path"),
109+
self.SHORTEST_PATH: tr("Shortest Path"),
106110
}[value]
107111

108112
def extract_value(self, dupe):
@@ -116,6 +120,10 @@ def sort_key(self, dupe, crit_value):
116120
return 0 if ends_with_digit else 1
117121
else:
118122
return 1 if ends_with_digit else 0
123+
elif crit_value == self.LONGEST_PATH:
124+
return len(str(dupe.folder_path)) * -1
125+
elif crit_value == self.SHORTEST_PATH:
126+
return len(str(dupe.folder_path))
119127
else:
120128
value = len(value)
121129
if crit_value == self.LONGEST:
@@ -130,6 +138,8 @@ def criteria_list(self):
130138
self.DOESNT_END_WITH_NUMBER,
131139
self.LONGEST,
132140
self.SHORTEST,
141+
self.LONGEST_PATH,
142+
self.SHORTEST_PATH,
133143
]
134144
]
135145

0 commit comments

Comments
 (0)