Skip to content

fastapi_tools.params.fastapi_tools_paths

Paths and folders for data files.

Classes:

FastapiToolsPaths

FastapiToolsPaths(env_type: EnvType)

Paths and folders for data and resources.

Load the config for data folders.

Methods:

Source code in src/fastapi_tools/params/fastapi_tools_paths.py
def __init__(
    self,
    env_type: EnvType,
) -> None:
    """Load the config for data folders."""
    self.env_type = env_type
    self.load_config()

__str__

__str__() -> str

Return the string representation of the object.

Source code in src/fastapi_tools/params/fastapi_tools_paths.py
def __str__(self) -> str:
    """Return the string representation of the object."""
    s = "FastapiToolsPaths:\n"
    s += f"      src_fol: {self.src_fol}\n"
    s += f"     root_fol: {self.root_fol}\n"
    s += f"    cache_fol: {self.cache_fol}\n"
    s += f"     data_fol: {self.data_fol}\n"
    s += f"   static_fol: {self.static_fol}\n"
    s += f"templates_fol: {self.templates_fol}\n"
    return s.rstrip()

load_common_config_pre

load_common_config_pre() -> None

Pre load the common config.

Source code in src/fastapi_tools/params/fastapi_tools_paths.py
def load_common_config_pre(self) -> None:
    """Pre load the common config."""
    # src folder of the package
    self.src_fol = Path(fastapi_tools.__file__).parent
    # root folder of the project repository
    self.root_fol = self.src_fol.parents[1]
    # cache
    self.cache_fol = self.root_fol / "cache"
    # data
    self.data_fol = self.root_fol / "data"
    # static
    self.static_fol = self.root_fol / "static"
    # templates
    self.templates_fol = self.root_fol / "templates"

load_config

load_config() -> None

Load the config for data folders.

Source code in src/fastapi_tools/params/fastapi_tools_paths.py
def load_config(self) -> None:
    """Load the config for data folders."""
    self.load_common_config_pre()
    match self.env_type.location:
        case EnvLocationType.LOCAL:
            self.load_local_config()
        case EnvLocationType.RENDER:
            self.load_render_config()
        case _:
            raise UnknownEnvLocationError(self.env_type.location)

load_local_config

load_local_config() -> None

Load the config for local environment.

Source code in src/fastapi_tools/params/fastapi_tools_paths.py
def load_local_config(self) -> None:
    """Load the config for local environment."""

load_render_config

load_render_config() -> None

Load the config for Render environment.

Source code in src/fastapi_tools/params/fastapi_tools_paths.py
def load_render_config(self) -> None:
    """Load the config for Render environment."""