Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create longest and shortest path criteria #1242

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading