Path 1: 4 calls (0.5)

'static/index.html' (4)

'rb' (2) 'r' (1) 'rt' (1)

BufferedReader (2) TextIOWrapper (2)

1def open_resource(self, resource: str, mode: str = "rb") -> t.IO[t.AnyStr]:
2        """Open a resource file relative to :attr:`root_path` for
3        reading.
4
5        For example, if the file ``schema.sql`` is next to the file
6        ``app.py`` where the ``Flask`` app is defined, it can be opened
7        with:
8
9        .. code-block:: python
10
11            with app.open_resource("schema.sql") as f:
12                conn.executescript(f.read())
13
14        :param resource: Path to the resource relative to
15            :attr:`root_path`.
16        :param mode: Open the file in this mode. Only reading is
17            supported, valid values are "r" (or "rt") and "rb".
18        """
19        if mode not in {"r", "rt", "rb"}:
20            raise ValueError("Resources can only be opened for reading.")
21
22        return open(os.path.join(self.root_path, resource), mode)
            

Path 2: 4 calls (0.5)

'static/index.html' (4)

'w' (1) 'x' (1) 'a' (1) 'r+' (1)

ValueError (4)

1def open_resource(self, resource: str, mode: str = "rb") -> t.IO[t.AnyStr]:
2        """Open a resource file relative to :attr:`root_path` for
3        reading.
4
5        For example, if the file ``schema.sql`` is next to the file
6        ``app.py`` where the ``Flask`` app is defined, it can be opened
7        with:
8
9        .. code-block:: python
10
11            with app.open_resource("schema.sql") as f:
12                conn.executescript(f.read())
13
14        :param resource: Path to the resource relative to
15            :attr:`root_path`.
16        :param mode: Open the file in this mode. Only reading is
17            supported, valid values are "r" (or "rt") and "rb".
18        """
19        if mode not in {"r", "rt", "rb"}:
20            raise ValueError("Resources can only be opened for reading.")
21
22        return open(os.path.join(self.root_path, resource), mode)