entry-points-txt


Nameentry-points-txt JSON
Version 0.2.1 PyPI version JSON
download
home_pageNone
SummaryRead & write entry_points.txt files
upload_time2024-12-01 12:40:47
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords entry points entry_points.txt
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            |repostatus| |ci-status| |coverage| |pyversions| |license|

.. |repostatus| image:: https://www.repostatus.org/badges/latest/active.svg
    :target: https://www.repostatus.org/#active
    :alt: Project Status: Active — The project has reached a stable, usable
          state and is being actively developed.

.. |ci-status| image:: https://github.com/wheelodex/entry-points-txt/actions/workflows/test.yml/badge.svg
    :target: https://github.com/wheelodex/entry-points-txt/actions/workflows/test.yml
    :alt: CI Status

.. |coverage| image:: https://codecov.io/gh/wheelodex/entry-points-txt/branch/master/graph/badge.svg
    :target: https://codecov.io/gh/wheelodex/entry-points-txt

.. |pyversions| image:: https://img.shields.io/pypi/pyversions/entry-points-txt.svg
    :target: https://pypi.org/project/entry-points-txt/

.. |license| image:: https://img.shields.io/github/license/wheelodex/entry-points-txt.svg
    :target: https://opensource.org/licenses/MIT
    :alt: MIT License

`GitHub <https://github.com/wheelodex/entry-points-txt>`_
| `PyPI <https://pypi.org/project/entry-points-txt/>`_
| `Issues <https://github.com/wheelodex/entry-points-txt/issues>`_
| `Changelog <https://github.com/wheelodex/entry-points-txt/blob/master/CHANGELOG.md>`_

``entry-points-txt`` provides functions for reading & writing
``entry_points.txt`` files according to `the spec`_.  That is the one thing it
does, and it endeavors to do it well.

.. _the spec: https://packaging.python.org/specifications/entry-points/

Installation
============
``entry-points-txt`` requires Python 3.8 or higher.  Just use `pip
<https://pip.pypa.io>`_ for Python 3 (You have pip, right?) to install
``entry-points-txt``::

    python3 -m pip install entry-points-txt


API
===

``EntryPoint``
--------------

.. code:: python

    class EntryPoint(NamedTuple)

A representation of an entry point as a namedtuple.  Instances have the
following attributes and methods:

``group: str``
   The name of the entry point group (e.g., ``"console_scripts"``)

``name: str``
   The name of the entry point

``module: str``
   The module portion of the attribute reference (the part before the colon)

``attr: Optional[str]``
   The attribute/object portion of the attribute reference (the part after the
   colon), or ``None`` if not specified

``extras: Tuple[str, ...]``
   Extras required for the entry point

``load() -> Any``
   Returns the object referred to by the entry point

``to_line() -> str``
   Returns the representation of the entry point as a line in
   ``entry_points.txt``, i.e., a line of the form ``name = module:attr
   [extras]``

``EntryPointSet``
-----------------

.. code:: python

    EntryPointSet = Dict[str, Dict[str, EntryPoint]]

An alias for the return type of ``load()`` & ``loads()`` and the argument type
of ``dump()`` & ``dumps()``.  Entry points are organized into a ``dict`` that
maps group names to sub-``dict``\s that map entry point names to ``EntryPoint``
instances.

``load()``
----------

.. code:: python

    entry_points_txt.load(fp: IO[str]) -> EntryPointSet

Parse a file-like object as an ``entry_points.txt``-format file and return the
results.

For example, the following input:

.. code:: ini

    [console_scripts]
    foo = package.__main__:main
    bar = package.cli:klass.attr

    [thingy.extension]
    quux = package.thingy [xtr]

would be parsed as:

.. code:: python

    {
        "console_scripts": {
            "foo": EntryPoint(group="console_scripts", name="foo", module="package.__main__", attr="main", extras=()),
            "bar": EntryPoint(group="console_scripts", name="bar", module="package.cli", attr="klass.attr", extras=()),
        },
        "thingy.extension": {
            "quux": EntryPoint(group="thingy.extension", name="quux", module="package.thingy", attr=None, extras=("xtr",)),
        },
    }

``loads()``
-----------

.. code:: python

    entry_points_txt.loads(s: str) -> EntryPointSet

Like ``load()``, but reads from a string instead of a filehandle

``dump()``
----------

.. code:: python

    entry_points_txt.dump(eps: EntryPointSet, fp: IO[str]) -> None

Write a collection of entry points to a file-like object in
``entry_points.txt`` format.  A ``ValueError`` is raised and nothing is written
if the group or name key under which an ``EntryPoint`` is located does not
match its ``group`` or ``name`` attribute.

``dumps()``
-----------

.. code:: python

    entry_points_txt.dumps(eps: EntryPointSet) -> str

Like ``dump()``, but returns a string instead of writing to a filehandle

``dump_list()``
---------------

.. code:: python

    entry_points_txt.dump_list(eps: Iterable[EntryPoint], fp: IO[str]) -> None

Write an iterable of entry points to a file-like object in ``entry_points.txt``
format.  If two or more entry points have the same group & name, only the last
one will be output.

``dumps_list()``
----------------

.. code:: python

    entry_points_txt.dumps_list(eps: Iterable[EntryPoint]) -> str

Like ``dump_list()``, but returns a string instead of writing to a filehandle

``ParseError``
--------------

.. code:: python

    class ParseError(ValueError)

Exception raised by ``load()`` or ``loads()`` when given invalid input

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "entry-points-txt",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "entry points, entry_points.txt",
    "author": null,
    "author_email": "John Thorvald Wodder II <entry-points-txt@varonathe.org>",
    "download_url": "https://files.pythonhosted.org/packages/df/53/3b6850a44344a538bb07efdad07aa85690ada7db36574cce1ba257226301/entry_points_txt-0.2.1.tar.gz",
    "platform": null,
    "description": "|repostatus| |ci-status| |coverage| |pyversions| |license|\n\n.. |repostatus| image:: https://www.repostatus.org/badges/latest/active.svg\n    :target: https://www.repostatus.org/#active\n    :alt: Project Status: Active \u2014 The project has reached a stable, usable\n          state and is being actively developed.\n\n.. |ci-status| image:: https://github.com/wheelodex/entry-points-txt/actions/workflows/test.yml/badge.svg\n    :target: https://github.com/wheelodex/entry-points-txt/actions/workflows/test.yml\n    :alt: CI Status\n\n.. |coverage| image:: https://codecov.io/gh/wheelodex/entry-points-txt/branch/master/graph/badge.svg\n    :target: https://codecov.io/gh/wheelodex/entry-points-txt\n\n.. |pyversions| image:: https://img.shields.io/pypi/pyversions/entry-points-txt.svg\n    :target: https://pypi.org/project/entry-points-txt/\n\n.. |license| image:: https://img.shields.io/github/license/wheelodex/entry-points-txt.svg\n    :target: https://opensource.org/licenses/MIT\n    :alt: MIT License\n\n`GitHub <https://github.com/wheelodex/entry-points-txt>`_\n| `PyPI <https://pypi.org/project/entry-points-txt/>`_\n| `Issues <https://github.com/wheelodex/entry-points-txt/issues>`_\n| `Changelog <https://github.com/wheelodex/entry-points-txt/blob/master/CHANGELOG.md>`_\n\n``entry-points-txt`` provides functions for reading & writing\n``entry_points.txt`` files according to `the spec`_.  That is the one thing it\ndoes, and it endeavors to do it well.\n\n.. _the spec: https://packaging.python.org/specifications/entry-points/\n\nInstallation\n============\n``entry-points-txt`` requires Python 3.8 or higher.  Just use `pip\n<https://pip.pypa.io>`_ for Python 3 (You have pip, right?) to install\n``entry-points-txt``::\n\n    python3 -m pip install entry-points-txt\n\n\nAPI\n===\n\n``EntryPoint``\n--------------\n\n.. code:: python\n\n    class EntryPoint(NamedTuple)\n\nA representation of an entry point as a namedtuple.  Instances have the\nfollowing attributes and methods:\n\n``group: str``\n   The name of the entry point group (e.g., ``\"console_scripts\"``)\n\n``name: str``\n   The name of the entry point\n\n``module: str``\n   The module portion of the attribute reference (the part before the colon)\n\n``attr: Optional[str]``\n   The attribute/object portion of the attribute reference (the part after the\n   colon), or ``None`` if not specified\n\n``extras: Tuple[str, ...]``\n   Extras required for the entry point\n\n``load() -> Any``\n   Returns the object referred to by the entry point\n\n``to_line() -> str``\n   Returns the representation of the entry point as a line in\n   ``entry_points.txt``, i.e., a line of the form ``name = module:attr\n   [extras]``\n\n``EntryPointSet``\n-----------------\n\n.. code:: python\n\n    EntryPointSet = Dict[str, Dict[str, EntryPoint]]\n\nAn alias for the return type of ``load()`` & ``loads()`` and the argument type\nof ``dump()`` & ``dumps()``.  Entry points are organized into a ``dict`` that\nmaps group names to sub-``dict``\\s that map entry point names to ``EntryPoint``\ninstances.\n\n``load()``\n----------\n\n.. code:: python\n\n    entry_points_txt.load(fp: IO[str]) -> EntryPointSet\n\nParse a file-like object as an ``entry_points.txt``-format file and return the\nresults.\n\nFor example, the following input:\n\n.. code:: ini\n\n    [console_scripts]\n    foo = package.__main__:main\n    bar = package.cli:klass.attr\n\n    [thingy.extension]\n    quux = package.thingy [xtr]\n\nwould be parsed as:\n\n.. code:: python\n\n    {\n        \"console_scripts\": {\n            \"foo\": EntryPoint(group=\"console_scripts\", name=\"foo\", module=\"package.__main__\", attr=\"main\", extras=()),\n            \"bar\": EntryPoint(group=\"console_scripts\", name=\"bar\", module=\"package.cli\", attr=\"klass.attr\", extras=()),\n        },\n        \"thingy.extension\": {\n            \"quux\": EntryPoint(group=\"thingy.extension\", name=\"quux\", module=\"package.thingy\", attr=None, extras=(\"xtr\",)),\n        },\n    }\n\n``loads()``\n-----------\n\n.. code:: python\n\n    entry_points_txt.loads(s: str) -> EntryPointSet\n\nLike ``load()``, but reads from a string instead of a filehandle\n\n``dump()``\n----------\n\n.. code:: python\n\n    entry_points_txt.dump(eps: EntryPointSet, fp: IO[str]) -> None\n\nWrite a collection of entry points to a file-like object in\n``entry_points.txt`` format.  A ``ValueError`` is raised and nothing is written\nif the group or name key under which an ``EntryPoint`` is located does not\nmatch its ``group`` or ``name`` attribute.\n\n``dumps()``\n-----------\n\n.. code:: python\n\n    entry_points_txt.dumps(eps: EntryPointSet) -> str\n\nLike ``dump()``, but returns a string instead of writing to a filehandle\n\n``dump_list()``\n---------------\n\n.. code:: python\n\n    entry_points_txt.dump_list(eps: Iterable[EntryPoint], fp: IO[str]) -> None\n\nWrite an iterable of entry points to a file-like object in ``entry_points.txt``\nformat.  If two or more entry points have the same group & name, only the last\none will be output.\n\n``dumps_list()``\n----------------\n\n.. code:: python\n\n    entry_points_txt.dumps_list(eps: Iterable[EntryPoint]) -> str\n\nLike ``dump_list()``, but returns a string instead of writing to a filehandle\n\n``ParseError``\n--------------\n\n.. code:: python\n\n    class ParseError(ValueError)\n\nException raised by ``load()`` or ``loads()`` when given invalid input\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Read & write entry_points.txt files",
    "version": "0.2.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/wheelodex/entry-points-txt/issues",
        "Source Code": "https://github.com/wheelodex/entry-points-txt"
    },
    "split_keywords": [
        "entry points",
        " entry_points.txt"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fb509bd6ef80640ce860767ca0f86673cee3c3f31f570cda54e9b36cb732a53a",
                "md5": "93d4a8ba22d4bd789567ccaa4a9c15e3",
                "sha256": "90abc88ac448b19c7ef08388a2ee066e2151da719cd6cbb6437b5deead5c808c"
            },
            "downloads": -1,
            "filename": "entry_points_txt-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "93d4a8ba22d4bd789567ccaa4a9c15e3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 6915,
            "upload_time": "2024-12-01T12:40:36",
            "upload_time_iso_8601": "2024-12-01T12:40:36.859118Z",
            "url": "https://files.pythonhosted.org/packages/fb/50/9bd6ef80640ce860767ca0f86673cee3c3f31f570cda54e9b36cb732a53a/entry_points_txt-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "df533b6850a44344a538bb07efdad07aa85690ada7db36574cce1ba257226301",
                "md5": "5ee2ba22436073396961625f4b9bad0d",
                "sha256": "2bca930f93d510cb1629c434954f7c7166b98c3cc968df7fd3fc270bc3cf06e9"
            },
            "downloads": -1,
            "filename": "entry_points_txt-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "5ee2ba22436073396961625f4b9bad0d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 8717,
            "upload_time": "2024-12-01T12:40:47",
            "upload_time_iso_8601": "2024-12-01T12:40:47.081312Z",
            "url": "https://files.pythonhosted.org/packages/df/53/3b6850a44344a538bb07efdad07aa85690ada7db36574cce1ba257226301/entry_points_txt-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-01 12:40:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "wheelodex",
    "github_project": "entry-points-txt",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "entry-points-txt"
}
        
Elapsed time: 0.36179s