lakehouse_engine.utils.storage.file_storage

Module for abstract representation of a storage system holding files.

 1"""Module for abstract representation of a storage system holding files."""
 2
 3from abc import ABC, abstractmethod
 4from typing import Any
 5from urllib.parse import ParseResult
 6
 7
 8class FileStorage(ABC):
 9    """Abstract file storage class."""
10
11    @classmethod
12    @abstractmethod
13    def get_file_payload(cls, url: ParseResult) -> Any:
14        """Get the payload of a file.
15
16        Args:
17            url: url of the file.
18
19        Returns:
20            File payload/content.
21        """
22        pass
23
24    @classmethod
25    @abstractmethod
26    def write_payload_to_file(cls, url: ParseResult, content: str) -> None:
27        """Write payload into a file.
28
29        Args:
30            url: url of the file.
31            content: content to write into the file.
32        """
33        pass
class FileStorage(abc.ABC):
 9class FileStorage(ABC):
10    """Abstract file storage class."""
11
12    @classmethod
13    @abstractmethod
14    def get_file_payload(cls, url: ParseResult) -> Any:
15        """Get the payload of a file.
16
17        Args:
18            url: url of the file.
19
20        Returns:
21            File payload/content.
22        """
23        pass
24
25    @classmethod
26    @abstractmethod
27    def write_payload_to_file(cls, url: ParseResult, content: str) -> None:
28        """Write payload into a file.
29
30        Args:
31            url: url of the file.
32            content: content to write into the file.
33        """
34        pass

Abstract file storage class.

@classmethod
@abstractmethod
def get_file_payload(cls, url: urllib.parse.ParseResult) -> Any:
12    @classmethod
13    @abstractmethod
14    def get_file_payload(cls, url: ParseResult) -> Any:
15        """Get the payload of a file.
16
17        Args:
18            url: url of the file.
19
20        Returns:
21            File payload/content.
22        """
23        pass

Get the payload of a file.

Arguments:
  • url: url of the file.
Returns:

File payload/content.

@classmethod
@abstractmethod
def write_payload_to_file(cls, url: urllib.parse.ParseResult, content: str) -> None:
25    @classmethod
26    @abstractmethod
27    def write_payload_to_file(cls, url: ParseResult, content: str) -> None:
28        """Write payload into a file.
29
30        Args:
31            url: url of the file.
32            content: content to write into the file.
33        """
34        pass

Write payload into a file.

Arguments:
  • url: url of the file.
  • content: content to write into the file.