4 # This is a >=3.7 module, so we conditionally include its source.
5 if sys.version_info >= (3, 7):
7 from contextlib import AbstractContextManager
8 from pathlib import Path
9 from types import ModuleType
10 from typing import BinaryIO, Iterator, TextIO, Union
12 Package = Union[str, ModuleType]
13 Resource = Union[str, os.PathLike[Any]]
14 def open_binary(package: Package, resource: Resource) -> BinaryIO: ...
15 def open_text(package: Package, resource: Resource, encoding: str = ..., errors: str = ...) -> TextIO: ...
16 def read_binary(package: Package, resource: Resource) -> bytes: ...
17 def read_text(package: Package, resource: Resource, encoding: str = ..., errors: str = ...) -> str: ...
18 def path(package: Package, resource: Resource) -> AbstractContextManager[Path]: ...
19 def is_resource(package: Package, name: str) -> bool: ...
20 def contents(package: Package) -> Iterator[str]: ...
22 if sys.version_info >= (3, 9):
23 from importlib.abc import Traversable
24 def files(package: Package) -> Traversable: ...
25 def as_file(path: Traversable) -> AbstractContextManager[Path]: ...