Skip to content

MagicStorage

This class instantiated and caches loaders which can be acquired with dedicated methods.

Resource storages are neither guaranteed to be cached, nor to be always newly created.

Source code in magic_storage/_magic.py
class MagicStorage:
    """This class instantiated and caches loaders which can be acquired with
    dedicated methods.

    Resource storages are neither guaranteed to be cached, nor to be
    always newly created.
    """

    def filesystem(self, __root: str | Path) -> FilesystemStorage:
        """Return local cache storage for current file. This object will be
        configured to use cache.

        Parameters
        ----------
        current_file : str
            Either directory or file, when file, its parent directory will be used.

        Returns
        -------
        FilesystemStorage
            new storage object.
        """
        return FilesystemStorage(__root)

    def filesystem_no_cache(self, __root: str | Path) -> FilesystemStorage:
        """Return local cache storage for current file. This object will be
        configured to not use cache.

        Parameters
        ----------
        current_file : str
            Either directory or file, when file, its parent directory will be used.

        Returns
        -------
        FilesystemStorage
            new storage object.
        """
        fs = FilesystemStorage(__root)
        fs.configure(cache=None)
        return fs

filesystem(__root) #

Return local cache storage for current file. This object will be configured to use cache.

Parameters:

Name Type Description Default
current_file str

Either directory or file, when file, its parent directory will be used.

required

Returns:

Type Description
FilesystemStorage

new storage object.

Source code in magic_storage/_magic.py
def filesystem(self, __root: str | Path) -> FilesystemStorage:
    """Return local cache storage for current file. This object will be
    configured to use cache.

    Parameters
    ----------
    current_file : str
        Either directory or file, when file, its parent directory will be used.

    Returns
    -------
    FilesystemStorage
        new storage object.
    """
    return FilesystemStorage(__root)

filesystem_no_cache(__root) #

Return local cache storage for current file. This object will be configured to not use cache.

Parameters:

Name Type Description Default
current_file str

Either directory or file, when file, its parent directory will be used.

required

Returns:

Type Description
FilesystemStorage

new storage object.

Source code in magic_storage/_magic.py
def filesystem_no_cache(self, __root: str | Path) -> FilesystemStorage:
    """Return local cache storage for current file. This object will be
    configured to not use cache.

    Parameters
    ----------
    current_file : str
        Either directory or file, when file, its parent directory will be used.

    Returns
    -------
    FilesystemStorage
        new storage object.
    """
    fs = FilesystemStorage(__root)
    fs.configure(cache=None)
    return fs

Last update: August 5, 2022
Created: August 5, 2022