Home / Function/ from_pyfile() — flask Function Reference

from_pyfile() — flask Function Reference

Architecture documentation for the from_pyfile() function in config.py from the flask codebase.

Entity Profile

Dependency Diagram

graph TD
  992a2a65_31c4_7dbd_d0e9_54f209631cda["from_pyfile()"]
  1e067a59_9e9f_8edb_0434_65b5c5690e36["Config"]
  992a2a65_31c4_7dbd_d0e9_54f209631cda -->|defined in| 1e067a59_9e9f_8edb_0434_65b5c5690e36
  64c4024a_6f73_9984_501a_d823589da302["from_envvar()"]
  64c4024a_6f73_9984_501a_d823589da302 -->|calls| 992a2a65_31c4_7dbd_d0e9_54f209631cda
  e968f33d_fca8_c3ea_6616_3fcd3d3dd07c["from_object()"]
  992a2a65_31c4_7dbd_d0e9_54f209631cda -->|calls| e968f33d_fca8_c3ea_6616_3fcd3d3dd07c
  style 992a2a65_31c4_7dbd_d0e9_54f209631cda fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/flask/config.py lines 187–216

    def from_pyfile(
        self, filename: str | os.PathLike[str], silent: bool = False
    ) -> bool:
        """Updates the values in the config from a Python file.  This function
        behaves as if the file was imported as module with the
        :meth:`from_object` function.

        :param filename: the filename of the config.  This can either be an
                         absolute filename or a filename relative to the
                         root path.
        :param silent: set to ``True`` if you want silent failure for missing
                       files.
        :return: ``True`` if the file was loaded successfully.

        .. versionadded:: 0.7
           `silent` parameter.
        """
        filename = os.path.join(self.root_path, filename)
        d = types.ModuleType("config")
        d.__file__ = filename
        try:
            with open(filename, mode="rb") as config_file:
                exec(compile(config_file.read(), filename, "exec"), d.__dict__)
        except OSError as e:
            if silent and e.errno in (errno.ENOENT, errno.EISDIR, errno.ENOTDIR):
                return False
            e.strerror = f"Unable to load configuration file ({e.strerror})"
            raise
        self.from_object(d)
        return True

Subdomains

Defined In

Called By

Frequently Asked Questions

What does from_pyfile() do?
from_pyfile() is a function in the flask codebase, defined in src/flask/config.py.
Where is from_pyfile() defined?
from_pyfile() is defined in src/flask/config.py at line 187.
What does from_pyfile() call?
from_pyfile() calls 1 function(s): from_object.
What calls from_pyfile()?
from_pyfile() is called by 1 function(s): from_envvar.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free