-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdirs.py
More file actions
27 lines (21 loc) · 964 Bytes
/
Copy pathdirs.py
File metadata and controls
27 lines (21 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python3
"""
Вам дана в архиве (ссылка) файловая структура, состоящая
из директорий и файлов.
Вам необходимо распаковать этот архив, и затем найти в данной
файловой структуре все директории, в которых есть хотя бы один файл
с расширением ".py".
Ответом на данную задачу будет являться файл со списком
таких директорий, отсортированных в лексикографическом порядке.
"""
import os
def find_dirs(fname):
res = list()
for curr, dirs, files in os.walk(fname):
if list(filter(lambda x: x.endswith(".py"), files)):
res.append("{}".format(curr))
res.sort()
return res
dirs = find_dirs("tests/main")
for dr in dirs:
print(dr)