Skip to content

Commit

Permalink
feat: Create longest and shortest path criteria (#1242)
Browse files Browse the repository at this point in the history
* Create longest and shortest path criteria
  • Loading branch information
Bostwickenator authored Aug 23, 2024
1 parent 3a97ba9 commit 8f197ea
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/prioritize.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,17 @@ class FilenameCategory(CriterionCategory):
DOESNT_END_WITH_NUMBER = 1
LONGEST = 2
SHORTEST = 3
LONGEST_PATH = 4
SHORTEST_PATH = 5

def format_criterion_value(self, value):
return {
self.ENDS_WITH_NUMBER: tr("Ends with number"),
self.DOESNT_END_WITH_NUMBER: tr("Doesn't end with number"),
self.LONGEST: tr("Longest"),
self.SHORTEST: tr("Shortest"),
self.LONGEST_PATH: tr("Longest Path"),
self.SHORTEST_PATH: tr("Shortest Path"),
}[value]

def extract_value(self, dupe):
Expand All @@ -116,6 +120,10 @@ def sort_key(self, dupe, crit_value):
return 0 if ends_with_digit else 1
else:
return 1 if ends_with_digit else 0
elif crit_value == self.LONGEST_PATH:
return len(str(dupe.folder_path)) * -1
elif crit_value == self.SHORTEST_PATH:
return len(str(dupe.folder_path))
else:
value = len(value)
if crit_value == self.LONGEST:
Expand All @@ -130,6 +138,8 @@ def criteria_list(self):
self.DOESNT_END_WITH_NUMBER,
self.LONGEST,
self.SHORTEST,
self.LONGEST_PATH,
self.SHORTEST_PATH,
]
]

Expand Down

0 comments on commit 8f197ea

Please sign in to comment.