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
34
35
36
37
38
39
40
41
42
43
44
45
|
from abc import ABC, abstractmethod
from typing import List
class FileSystem(ABC):
"""An abstract filesystem that can read/write from a set of files."""
@abstractmethod
def read(self, path) -> str:
raise NotImplementedError
@abstractmethod
def readlines(self, path) -> List[str]:
raise NotImplementedError
@abstractmethod
def write(self, path, content):
raise NotImplementedError
@abstractmethod
def exists(self, path) -> bool:
raise NotImplementedError
@abstractmethod
def rename_file(self, filepath: str, new_filepath: str):
raise NotImplementedError
@abstractmethod
def walk(self, path: str) -> List[str]:
raise NotImplementedError
@abstractmethod
def rename_directory(self, path: str, new_path: str):
raise NotImplementedError
@abstractmethod
def delete_file(self, filepath: str):
raise NotImplementedError
@abstractmethod
def delete_directory(self, path: str):
raise NotImplementedError
@abstractmethod
def add_directory(self, path: str):
raise NotImplementedError
|