Skip to content

Add .open() to the Traversable API #81

Closed
@jaraco

Description

@jaraco

In GitLab by @jaraco on Feb 29, 2020, 19:13

As is implied by the migration guide, Traversable objects require a .open() method.

The interface needs to be a limited subset of the usual open() operation, but it's basically this:

def open(self, mode='r', *args, **kwargs):
    """
    mode may be 'r' or 'rb' to open as text or binary. Return a handle
    suitable for reading (same as pathlib.Path.open).

    When opening as text, accepts encoding parameters such as those
    accepted by io.TextIOWrapper.
    """

Note, only with zipp 3.0 (and the Python 2 compatible zipp 1.2.0) does the zipp.Path object have a compatible interface, so importlib_resources should depend on these versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions