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 |
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 |
True if `name` is a resource inside `package`. |
Function | open |
Return a file-like object opened for binary reading of the resource. |
Function | open |
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 |
Return the binary contents of the resource. |
Function | read |
Return the decoded string of the resource. |
Type Alias |
|
Undocumented |
Given a Traversable object, return that object as a path on the local file system in a context manager.
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.
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.
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().
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).