Skip to content

Commit e21abf0

Browse files
authored
Merge branch 'dostonnabotov:main' into main
2 parents 9332601 + 159f0de commit e21abf0

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
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')",

public/data/python.json

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -187,17 +187,13 @@
187187
"import os",
188188
"",
189189
"def find_files(directory, file_type):",
190-
" file_type = file_type.lower() # Convert file_type to lowercase",
191-
" found_files = []",
190+
" file_type = file_type.lower()",
191+
" found_files = []",
192192
"",
193-
" for root, _, files in os.walk(directory):",
194-
" for file in files:",
195-
" file_ext = os.path.splitext(file)[1].lower()",
196-
" if file_ext == file_type:",
197-
" full_path = os.path.join(root, file)",
198-
" found_files.append(full_path)",
199-
"",
200-
" return found_files",
193+
" for entry in os.scandir(directory):",
194+
" if entry.is_file() and entry.name.lower().endswith(file_type):",
195+
" found_files.append(entry.name)",
196+
" return found_files",
201197
"",
202198
"# Example Usage:",
203199
"pdf_files = find_files('/path/to/your/directory', '.pdf')",

0 commit comments

Comments
 (0)