Skip to content

Commit

Permalink
Initial impl
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Sep 6, 2024
1 parent 4ce312f commit a45d34d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions singer_sdk/contrib/filesystem/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Filesystem interfaces for the Singer SDK."""
39 changes: 39 additions & 0 deletions singer_sdk/contrib/filesystem/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""Abstract classes for file system operations."""

from __future__ import annotations

Check warning on line 3 in singer_sdk/contrib/filesystem/base.py

View check run for this annotation

Codecov / codecov/patch

singer_sdk/contrib/filesystem/base.py#L3

Added line #L3 was not covered by tests

import abc
import typing as t

Check warning on line 6 in singer_sdk/contrib/filesystem/base.py

View check run for this annotation

Codecov / codecov/patch

singer_sdk/contrib/filesystem/base.py#L5-L6

Added lines #L5 - L6 were not covered by tests


class AbstractFile(abc.ABC):

Check warning on line 9 in singer_sdk/contrib/filesystem/base.py

View check run for this annotation

Codecov / codecov/patch

singer_sdk/contrib/filesystem/base.py#L9

Added line #L9 was not covered by tests
"""Abstract class for file operations."""

@abc.abstractmethod
def read(self) -> bytes:
"""Read the file contents."""


Node = t.Union[AbstractFile, "AbstractDirectory"]

Check warning on line 17 in singer_sdk/contrib/filesystem/base.py

View check run for this annotation

Codecov / codecov/patch

singer_sdk/contrib/filesystem/base.py#L17

Added line #L17 was not covered by tests


class AbstractDirectory(abc.ABC):

Check warning on line 20 in singer_sdk/contrib/filesystem/base.py

View check run for this annotation

Codecov / codecov/patch

singer_sdk/contrib/filesystem/base.py#L20

Added line #L20 was not covered by tests
"""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):

Check warning on line 34 in singer_sdk/contrib/filesystem/base.py

View check run for this annotation

Codecov / codecov/patch

singer_sdk/contrib/filesystem/base.py#L34

Added line #L34 was not covered by tests
"""Abstract class for file system operations."""

@abc.abstractmethod
def open(self, path: str) -> AbstractFile:
"""Open a file for reading."""

0 comments on commit a45d34d

Please sign in to comment.