-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.py
More file actions
26 lines (20 loc) · 1002 Bytes
/
interface.py
File metadata and controls
26 lines (20 loc) · 1002 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
import os
from abc import ABC, abstractmethod
from typing import Iterable, Set
from ..file_info_extractor import IFileInfoExtractor
class IProjectInfoExtractor(ABC):
def __init__(self, file_info_extractor: IFileInfoExtractor):
self._file_info_extractor = file_info_extractor
@abstractmethod
def get_workspace_root(self) -> str:
raise NotImplementedError
def get_all_files_filter_by_exts(self, exts: Set[str]) -> Iterable[str]:
for root, _, files in os.walk(self.get_workspace_root()):
for file in files:
if self._file_info_extractor.get_file_ext(file) in exts:
yield os.path.join(root, file)
def get_all_files_filter_by_file_type(self, file_types: Set[str]) -> Iterable[str]:
for root, _, files in os.walk(self.get_workspace_root()):
for file in files:
if self._file_info_extractor.get_file_type(file) in file_types:
yield os.path.join(root, file)