Skip to content

Commit

Permalink
refactor: rename method
Browse files Browse the repository at this point in the history
Also improve readability
  • Loading branch information
roryai committed Jan 8, 2024
1 parent bfb4487 commit 5a353e2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/filepath_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand All @@ -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

Expand Down

0 comments on commit 5a353e2

Please sign in to comment.