-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ce312f
commit a45d34d
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Filesystem interfaces for the Singer SDK.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
"""Abstract classes for file system operations.""" | ||
|
||
from __future__ import annotations | ||
|
||
import abc | ||
import typing as t | ||
|
||
|
||
class AbstractFile(abc.ABC): | ||
"""Abstract class for file operations.""" | ||
|
||
@abc.abstractmethod | ||
def read(self) -> bytes: | ||
"""Read the file contents.""" | ||
|
||
|
||
Node = t.Union[AbstractFile, "AbstractDirectory"] | ||
|
||
|
||
class AbstractDirectory(abc.ABC): | ||
"""Abstract class for directory operations.""" | ||
|
||
@abc.abstractmethod | ||
def list_contents(self) -> t.Generator[Node, None, None]: | ||
"""List files in the directory. | ||
Yields: | ||
A file or directory node | ||
""" | ||
yield self | ||
yield from [] | ||
|
||
|
||
class AbstractFileSystem(abc.ABC): | ||
"""Abstract class for file system operations.""" | ||
|
||
@abc.abstractmethod | ||
def open(self, path: str) -> AbstractFile: | ||
"""Open a file for reading.""" |