-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.py
More file actions
33 lines (23 loc) · 675 Bytes
/
next.py
File metadata and controls
33 lines (23 loc) · 675 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
28
29
30
31
32
33
import os
from typing import Optional
def next(num_class: str) -> Optional[str]:
"""The function returns the next element path by class label
Args:
num_class (str): class label
Returns:
Optional[str]: path to file
Yields:
Iterator[Optional[str]]: path to file
"""
path = os.path.join('dataset', num_class)
class_names = os.listdir(path)
class_names.append(None)
for i in range(len(class_names)):
if class_names[i] is not None:
yield os.path.join(path, class_names[i])
else:
yield None
def main() -> None:
print(*next('1'))
if __name__ == '__main__':
main()