From 5a353e2acab67ab6a0975efc465ef926806d957a Mon Sep 17 00:00:00 2001 From: Rory Date: Mon, 8 Jan 2024 17:19:22 +0000 Subject: [PATCH] refactor: rename method Also improve readability --- app/filepath_generator.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/filepath_generator.py b/app/filepath_generator.py index 2101199..eb499a5 100644 --- a/app/filepath_generator.py +++ b/app/filepath_generator.py @@ -14,9 +14,10 @@ def generate_destination_filepath(self): filename = p(self.source_filepath).name file_birthtime = self.__earliest_approximation_of_file_creation_time() quarter = self.__determine_quarter(file_birthtime.month) - prospective_destination_filepath = os.path.join(self.destination_directory, str(file_birthtime.year), quarter, filename) + prospective_destination_filepath = os.path.join( + self.destination_directory, str(file_birthtime.year), quarter, filename) - return self.__detect_duplicates(prospective_destination_filepath) + return self.__resolve_path(prospective_destination_filepath) def __earliest_approximation_of_file_creation_time(self): birthtime_in_seconds = p(self.source_filepath).stat().st_birthtime @@ -37,7 +38,7 @@ def __determine_quarter(self, month): case _: raise TypeError - def __detect_duplicates(self, destination_filepath): + def __resolve_path(self, destination_filepath): if not self.__path_in_use(destination_filepath): return destination_filepath if self.__destination_and_source_files_are_same_size(destination_filepath): @@ -56,7 +57,7 @@ def __generate_next_available_path(self, destination_filepath): filename = self.__add_suffix(path.stem) incremented_path = f'{path.parent}/{filename}{path.suffix}' if self.__path_in_use(incremented_path): - return self.__detect_duplicates(incremented_path) + return self.__resolve_path(incremented_path) else: return incremented_path