From b0171164ea2337f36528d8c340259edc83ca975c Mon Sep 17 00:00:00 2001 From: "HOME-2022\\User" Date: Fri, 14 Jun 2024 20:40:42 +0300 Subject: [PATCH] improved docs --- duplicate_files_in_folders/utils.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/duplicate_files_in_folders/utils.py b/duplicate_files_in_folders/utils.py index 3125b34..0a27d4b 100644 --- a/duplicate_files_in_folders/utils.py +++ b/duplicate_files_in_folders/utils.py @@ -13,7 +13,8 @@ def detect_pytest(): - """ Detect if the script is run by pytest. """ + """ Detect if the script is run by pytest. + :return: True if the script is run by pytest, False otherwise""" return 'PYTEST_CURRENT_TEST' in os.environ @@ -99,9 +100,6 @@ def parse_arguments(cust_args=None, check_folders=True): parser.add_argument('--action', type=str, choices=['move_duplicates', 'create_csv'], help='Action to perform: move_duplicates, create_csv', default='move_duplicates') - - - args = parser.parse_args(cust_args if cust_args else None) # Validate the folders given in the arguments @@ -206,7 +204,7 @@ def check_and_update_filename(original_filename: str, renaming_function=lambda o Check if the filename already exists and rename it to avoid overwriting. :param original_filename: the original filename :param renaming_function: function that receives the original filename and returns the new filename - :return: + :return: the new filename if the original filename exists, otherwise the original filename """ new_filename = original_filename if os.path.exists(original_filename): @@ -219,6 +217,9 @@ def get_file_key(args: Namespace, file_path: str) -> str: """ Generate a unique key for the file based on hash, filename, and modified date. Ignores components based on args. Example: 'hash_key_filename_mdate' or 'hash_key_mdate' or 'hash_key_filename' or 'hash_key' + :param args: the parsed arguments + :param file_path: the full path of the file + :return: the unique key for the file """ hash_key: str = HashManager.get_instance().get_hash(file_path) file_key: str = file_path[file_path.rfind(os.sep) + 1:] if 'filename' not in args.ignore_diff else None