Skip to content

Commit 159f0de

Browse files
committed
Update consolidated snippets
1 parent f8ff933 commit 159f0de

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

public/consolidated/all_snippets.json

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,17 +1299,13 @@
12991299
"import os",
13001300
"",
13011301
"def find_files(directory, file_type):",
1302-
" file_type = file_type.lower() # Convert file_type to lowercase",
1303-
" found_files = []",
1302+
" file_type = file_type.lower()",
1303+
" found_files = []",
13041304
"",
1305-
" for root, _, files in os.walk(directory):",
1306-
" for file in files:",
1307-
" file_ext = os.path.splitext(file)[1].lower()",
1308-
" if file_ext == file_type:",
1309-
" full_path = os.path.join(root, file)",
1310-
" found_files.append(full_path)",
1311-
"",
1312-
" return found_files",
1305+
" for entry in os.scandir(directory):",
1306+
" if entry.is_file() and entry.name.lower().endswith(file_type):",
1307+
" found_files.append(entry.name)",
1308+
" return found_files",
13131309
"",
13141310
"# Example Usage:",
13151311
"pdf_files = find_files('/path/to/your/directory', '.pdf')",

0 commit comments

Comments
 (0)