From c80a7fd5a7102a6154a5a1b881a7842ede4b7d74 Mon Sep 17 00:00:00 2001 From: Sviatoslav Tsariov Date: Thu, 23 Mar 2023 11:41:45 +0300 Subject: [PATCH] cleanup --- server/model/file_provide.txt | 36 ----------------------------------- 1 file changed, 36 deletions(-) delete mode 100644 server/model/file_provide.txt diff --git a/server/model/file_provide.txt b/server/model/file_provide.txt deleted file mode 100644 index a9e6b62..0000000 --- a/server/model/file_provide.txt +++ /dev/null @@ -1,36 +0,0 @@ -def has_allowed_extension(name, allowed_file_endings=None): - if not allowed_file_endings: - return True - - return any(name.endswith(file_ending) for file_ending in allowed_file_endings) - -def collect_nested_files(directory_path, forbidden_dir_names=None, allowed_file_endings=None, collected_paths=None): - if forbidden_dir_names is None: - forbidden_dir_names = ['env', '.git', '__pycache__', 'server'] - - if allowed_file_endings is None: - allowed_file_endings = ['.md'] - - if collected_paths is None: - collected_paths = (directory_path, []) - - if any(name in directory_path.split(os.path.sep) for name in forbidden_dir_names): - return collected_paths - - subpaths = collected_paths[1] - - nested_list = sorted(os.listdir(directory_path)) - - for name in nested_list: - nested_path = os.path.join(directory_path, name) - - if os.path.isdir(nested_path): - nested_dir = collect_nested_files(nested_path, collected_paths=(nested_path, [])) - if nested_dir[1]: - subpaths.append(nested_dir) - else: - if not has_allowed_extension(name, allowed_file_endings=allowed_file_endings): - continue - subpaths.append(nested_path) - - return collected_paths \ No newline at end of file