Skip to content

Commit

Permalink
Remove documentation for removed functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jul 7, 2023
1 parent a1bac45 commit 7de5d88
Showing 1 changed file with 0 additions and 156 deletions.
156 changes: 0 additions & 156 deletions Doc/library/importlib.resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,159 +94,3 @@ for example, a package and its resources can be imported from a zip file using
the file system is required.

.. versionadded:: 3.9


Deprecated functions
^^^^^^^^^^^^^^^^^^^^

An older, deprecated set of functions is still available, but is
scheduled for removal in a future version of Python.
The main drawback of these functions is that they do not support
directories: they assume all resources are located directly within a *package*.

.. data:: Package

Whenever a function accepts a ``Package`` argument, you can pass in
either a :class:`module object <types.ModuleType>` or a module name
as a string. You can only pass module objects whose
``__spec__.submodule_search_locations`` is not ``None``.

The ``Package`` type is defined as ``Union[str, ModuleType]``.

.. deprecated:: 3.12


.. data:: Resource

For *resource* arguments of the functions below, you can pass in
the name of a resource as a string or
a :class:`path-like object <os.PathLike>`.

The ``Resource`` type is defined as ``Union[str, os.PathLike]``.


.. function:: open_binary(package, resource)

Open for binary reading the *resource* within *package*.

*package* is either a name or a module object which conforms to the
``Package`` requirements. *resource* is the name of the resource to open
within *package*; it may not contain path separators and it may not have
sub-resources (i.e. it cannot be a directory). This function returns a
``typing.BinaryIO`` instance, a binary I/O stream open for reading.

.. deprecated:: 3.11

Calls to this function can be replaced by::

files(package).joinpath(resource).open('rb')


.. function:: open_text(package, resource, encoding='utf-8', errors='strict')

Open for text reading the *resource* within *package*. By default, the
resource is opened for reading as UTF-8.

*package* is either a name or a module object which conforms to the
``Package`` requirements. *resource* is the name of the resource to open
within *package*; it may not contain path separators and it may not have
sub-resources (i.e. it cannot be a directory). *encoding* and *errors*
have the same meaning as with built-in :func:`open`.

This function returns a ``typing.TextIO`` instance, a text I/O stream open
for reading.

.. deprecated:: 3.11

Calls to this function can be replaced by::

files(package).joinpath(resource).open('r', encoding=encoding)


.. function:: read_binary(package, resource)

Read and return the contents of the *resource* within *package* as
``bytes``.

*package* is either a name or a module object which conforms to the
``Package`` requirements. *resource* is the name of the resource to open
within *package*; it may not contain path separators and it may not have
sub-resources (i.e. it cannot be a directory). This function returns the
contents of the resource as :class:`bytes`.

.. deprecated:: 3.11

Calls to this function can be replaced by::

files(package).joinpath(resource).read_bytes()


.. function:: read_text(package, resource, encoding='utf-8', errors='strict')

Read and return the contents of *resource* within *package* as a ``str``.
By default, the contents are read as strict UTF-8.

*package* is either a name or a module object which conforms to the
``Package`` requirements. *resource* is the name of the resource to open
within *package*; it may not contain path separators and it may not have
sub-resources (i.e. it cannot be a directory). *encoding* and *errors*
have the same meaning as with built-in :func:`open`. This function
returns the contents of the resource as :class:`str`.

.. deprecated:: 3.11

Calls to this function can be replaced by::

files(package).joinpath(resource).read_text(encoding=encoding)


.. function:: path(package, resource)

Return the path to the *resource* as an actual file system path. This
function returns a context manager for use in a :keyword:`with` statement.
The context manager provides a :class:`pathlib.Path` object.

Exiting the context manager cleans up any temporary file created when the
resource needs to be extracted from e.g. a zip file.

*package* is either a name or a module object which conforms to the
``Package`` requirements. *resource* is the name of the resource to open
within *package*; it may not contain path separators and it may not have
sub-resources (i.e. it cannot be a directory).

.. deprecated:: 3.11

Calls to this function can be replaced using :func:`as_file`::

as_file(files(package).joinpath(resource))


.. function:: is_resource(package, name)

Return ``True`` if there is a resource named *name* in the package,
otherwise ``False``.
This function does not consider directories to be resources.
*package* is either a name or a module object which conforms to the
``Package`` requirements.

.. deprecated:: 3.11

Calls to this function can be replaced by::

files(package).joinpath(resource).is_file()


.. function:: contents(package)

Return an iterable over the named items within the package. The iterable
returns :class:`str` resources (e.g. files) and non-resources
(e.g. directories). The iterable does not recurse into subdirectories.

*package* is either a name or a module object which conforms to the
``Package`` requirements.

.. deprecated:: 3.11

Calls to this function can be replaced by::

(resource.name for resource in files(package).iterdir() if resource.is_file())

0 comments on commit 7de5d88

Please sign in to comment.