package documentation

Read resources contained within a package.

Module abc No module docstring; 0/1 exception, 3/3 classes documented
Module readers No module docstring; 0/1 function, 1/4 class documented
Module simple Interface adapters for low-level readers.
Package tests No package docstring; 1/12 module, 0/4 package documented
Module _adapters No module docstring; 1/2 function, 3/3 classes documented
Module _common No module docstring; 8/12 functions documented
Module _compat No module docstring; 0/1 type alias, 1/1 function, 1/1 class documented
Module _itertools No module docstring; 0/2 type variable, 1/1 function documented
Module _legacy No module docstring; 0/1 type alias, 1/2 function documented

From __init__.py:

Function as_file Given a Traversable object, return that object as a path on the local file system in a context manager.
Function contents Return an iterable of entries in `package`.
Function files Get a Traversable resource for an anchor.
Function is_resource True if `name` is a resource inside `package`.
Function open_binary Return a file-like object opened for binary reading of the resource.
Function open_text Return a file-like object opened for text reading of the resource.
Function path A context manager providing a file path object to the resource.
Function read_binary Return the binary contents of the resource.
Function read_text Return the decoded string of the resource.
Type Alias Package Undocumented

Given a Traversable object, return that object as a path on the local file system in a context manager.

@package_to_anchor
def files(anchor: Optional[Anchor] = None) -> Traversable: (source)

Get a Traversable resource for an anchor.

Undocumented

Value
Union[types.ModuleType, str]
@deprecated
def contents(package: Package) -> Iterable[str]: (source)

Return an iterable of entries in `package`. Note that not all entries are resources. Specifically, directories are not considered resources. Use `is_resource()` on each entry returned here to check if it is a resource or not.

@deprecated
def open_binary(package: Package, resource: Resource) -> BinaryIO: (source)

Return a file-like object opened for binary reading of the resource.

@deprecated
def read_binary(package: Package, resource: Resource) -> bytes: (source)

Return the binary contents of the resource.

@deprecated
def open_text(package: Package, resource: Resource, encoding: str = 'utf-8', errors: str = 'strict') -> TextIO: (source)

Return a file-like object opened for text reading of the resource.

@deprecated
def read_text(package: Package, resource: Resource, encoding: str = 'utf-8', errors: str = 'strict') -> str: (source)

Return the decoded string of the resource. The decoding-related arguments have the same semantics as those of bytes.decode().

@deprecated
def is_resource(package: Package, name: str) -> bool: (source)

True if `name` is a resource inside `package`. Directories are *not* resources.

@deprecated
def path(package: Package, resource: Resource) -> ContextManager[pathlib.Path]: (source)

A context manager providing a file path object to the resource. If the resource does not already exist on its own on the file system, a temporary file will be created. If the file was created, the file will be deleted upon exiting the context manager (no exception is raised if the file was deleted prior to the context manager exiting).