curies


Namecuries JSON
Version 0.7.9 PyPI version JSON
download
home_pagehttps://github.com/cthoyt/curies
SummaryIdiomatic conversion between URIs and compact URIs (CURIEs).
upload_time2024-04-03 08:13:59
maintainerCharles Tapley Hoyt
docs_urlNone
authorCharles Tapley Hoyt
requires_python>=3.8
licenseMIT
keywords snekpack cookiecutter semantic web compact uniform resource identifiers uniform resource identifiers curies iris
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <!--
<p align="center">
  <img src="https://github.com/cthoyt/curies/raw/main/docs/source/logo.png" height="150">
</p>
-->

<h1 align="center">
  curies
</h1>

<p align="center">
    <a href="https://github.com/biopragmatics/curies/actions/workflows/tests.yml">
        <img alt="Tests" src="https://github.com/biopragmatics/curies/actions/workflows/tests.yml/badge.svg" />
    </a>
    <a href="https://pypi.org/project/curies">
        <img alt="PyPI" src="https://img.shields.io/pypi/v/curies" />
    </a>
    <a href="https://pypi.org/project/curies">
        <img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/curies" />
    </a>
    <a href="https://github.com/cthoyt/curies/blob/main/LICENSE">
        <img alt="PyPI - License" src="https://img.shields.io/pypi/l/curies" />
    </a>
    <a href='https://curies.readthedocs.io/en/latest/?badge=latest'>
        <img src='https://readthedocs.org/projects/curies/badge/?version=latest' alt='Documentation Status' />
    </a>
    <a href="https://codecov.io/gh/cthoyt/curies/branch/main">
        <img src="https://codecov.io/gh/cthoyt/curies/branch/main/graph/badge.svg" alt="Codecov status" />
    </a>
    <a href="https://github.com/cthoyt/cookiecutter-python-package">
        <img alt="Cookiecutter template from @cthoyt" src="https://img.shields.io/badge/Cookiecutter-snekpack-blue" />
    </a>
    <a href='https://github.com/psf/black'>
        <img src='https://img.shields.io/badge/code%20style-black-000000.svg' alt='Code style: black' />
    </a>
    <a href="https://github.com/cthoyt/curies/blob/main/.github/CODE_OF_CONDUCT.md">
        <img src="https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg" alt="Contributor Covenant"/>
    </a>
    <a href="https://zenodo.org/badge/latestdoi/519905487">
        <img src="https://zenodo.org/badge/519905487.svg" alt="DOI">
    </a>
</p>

Idiomatic conversion between URIs and compact URIs (CURIEs).

```python
import curies

converter = curies.load_prefix_map({
    "CHEBI": "http://purl.obolibrary.org/obo/CHEBI_",
    # ... and so on
})

>>> converter.compress("http://purl.obolibrary.org/obo/CHEBI_1")
'CHEBI:1'

>>> converter.expand("CHEBI:1")
'http://purl.obolibrary.org/obo/CHEBI_1'
```

Full documentation is available at [curies.readthedocs.io](https://curies.readthedocs.io).

### CLI Usage

This package comes with a built-in CLI for running a resolver web application or a IRI mapper web application:

```shell
# Run a resolver
python -m curies resolver --host 0.0.0.0 --port 8764 bioregistry

# Run a mapper
python -m curies mapper --host 0.0.0.0 --port 8764 bioregistry
```

The positional argument can be one of the following:

1. A pre-defined prefix map to get from the web (bioregistry, go, obo, monarch, prefixcommons)
2. A local file path or URL to a prefix map, extended prefix map, or one of several formats. Requires specifying
   a `--format`.

The framework can be swapped to use Flask (default) or FastAPI with `--framework`. The
server can be swapped to use Werkzeug (default) or Uvicorn with `--server`. These functionalities
are also available programmatically, see the docs for more information.

## 🧑‍🤝‍🧑 Related

Other packages that convert between CURIEs and URIs:

- https://github.com/prefixcommons/prefixcommons-py (Python)
- https://github.com/prefixcommons/curie-util (Java)
- https://github.com/geneontology/curie-util-py (Python)
- https://github.com/geneontology/curie-util-es5 (Node.js)
- https://github.com/endoli/curie.rs (Rust)
- https://github.com/cthoyt/curies4j (Java)
- https://github.com/biopragmatics/curies.rs (Rust, Node.js, Python)

## 🚀 Installation

The most recent release can be installed from
[PyPI](https://pypi.org/project/curies/) with:

```bash
$ pip install curies
```

This package currently supports both Pydantic v1 and v2. See the
[Pydantic migration guide](https://docs.pydantic.dev/2.0/migration/)
for updating your code.

## 👐 Contributing

Contributions, whether filing an issue, making a pull request, or forking, are appreciated. See
[CONTRIBUTING.md](https://github.com/cthoyt/curies/blob/master/.github/CONTRIBUTING.md) for more information on getting
involved.

## 👋 Attribution

### 🙏 Acknowledgements

This package heavily builds on the [trie](https://en.wikipedia.org/wiki/Trie)
data structure implemented in [`pytrie`](https://github.com/gsakkis/pytrie).

### ⚖️ License

The code in this package is licensed under the MIT License.

### 🍪 Cookiecutter

This package was created with [@audreyfeldroy](https://github.com/audreyfeldroy)'s
[cookiecutter](https://github.com/cookiecutter/cookiecutter) package using [@cthoyt](https://github.com/cthoyt)'s
[cookiecutter-snekpack](https://github.com/cthoyt/cookiecutter-snekpack) template.

## 🛠️ For Developers

<details>
  <summary>See developer instructions</summary>


The final section of the README is for if you want to get involved by making a code contribution.

### Development Installation

To install in development mode, use the following:

```bash
$ git clone git+https://github.com/cthoyt/curies.git
$ cd curies
$ pip install -e .
```

### 🥼 Testing

After cloning the repository and installing `tox` with `pip install tox`, the unit tests in the `tests/` folder can be
run reproducibly with:

```shell
$ tox
```

Additionally, these tests are automatically re-run with each commit in a [GitHub Action](https://github.com/cthoyt/curies/actions?query=workflow%3ATests).

### 📖 Building the Documentation

The documentation can be built locally using the following:

```shell
$ git clone git+https://github.com/cthoyt/curies.git
$ cd curies
$ tox -e docs
$ open docs/build/html/index.html
```

The documentation automatically installs the package as well as the `docs`
extra specified in the [`setup.cfg`](setup.cfg). `sphinx` plugins
like `texext` can be added there. Additionally, they need to be added to the
`extensions` list in [`docs/source/conf.py`](docs/source/conf.py).

### 📦 Making a Release

After installing the package in development mode and installing
`tox` with `pip install tox`, the commands for making a new release are contained within the `finish` environment
in `tox.ini`. Run the following from the shell:

```shell
$ tox -e finish
```

This script does the following:

1. Uses [Bump2Version](https://github.com/c4urself/bump2version) to switch the version number in the `setup.cfg`,
   `src/curies/version.py`, and [`docs/source/conf.py`](docs/source/conf.py) to not have the `-dev` suffix
2. Packages the code in both a tar archive and a wheel using [`build`](https://github.com/pypa/build)
3. Uploads to PyPI using [`twine`](https://github.com/pypa/twine). Be sure to have a `.pypirc` file configured to avoid the need for manual input at this
   step
4. Push to GitHub. You'll need to make a release going with the commit where the version was bumped.
5. Bump the version to the next patch. If you made big changes and want to bump the version by minor, you can
   use `tox -e bumpversion minor` after.

</details>

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cthoyt/curies",
    "name": "curies",
    "maintainer": "Charles Tapley Hoyt",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "cthoyt@gmail.com",
    "keywords": "snekpack, cookiecutter, semantic web, compact uniform resource identifiers, uniform resource identifiers, curies, IRIs",
    "author": "Charles Tapley Hoyt",
    "author_email": "cthoyt@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/65/d0/143fa90df55e5e5b1a0408f43a2e84c7f76293083a7ba63546b33cff31f6/curies-0.7.9.tar.gz",
    "platform": null,
    "description": "<!--\n<p align=\"center\">\n  <img src=\"https://github.com/cthoyt/curies/raw/main/docs/source/logo.png\" height=\"150\">\n</p>\n-->\n\n<h1 align=\"center\">\n  curies\n</h1>\n\n<p align=\"center\">\n    <a href=\"https://github.com/biopragmatics/curies/actions/workflows/tests.yml\">\n        <img alt=\"Tests\" src=\"https://github.com/biopragmatics/curies/actions/workflows/tests.yml/badge.svg\" />\n    </a>\n    <a href=\"https://pypi.org/project/curies\">\n        <img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/curies\" />\n    </a>\n    <a href=\"https://pypi.org/project/curies\">\n        <img alt=\"PyPI - Python Version\" src=\"https://img.shields.io/pypi/pyversions/curies\" />\n    </a>\n    <a href=\"https://github.com/cthoyt/curies/blob/main/LICENSE\">\n        <img alt=\"PyPI - License\" src=\"https://img.shields.io/pypi/l/curies\" />\n    </a>\n    <a href='https://curies.readthedocs.io/en/latest/?badge=latest'>\n        <img src='https://readthedocs.org/projects/curies/badge/?version=latest' alt='Documentation Status' />\n    </a>\n    <a href=\"https://codecov.io/gh/cthoyt/curies/branch/main\">\n        <img src=\"https://codecov.io/gh/cthoyt/curies/branch/main/graph/badge.svg\" alt=\"Codecov status\" />\n    </a>\n    <a href=\"https://github.com/cthoyt/cookiecutter-python-package\">\n        <img alt=\"Cookiecutter template from @cthoyt\" src=\"https://img.shields.io/badge/Cookiecutter-snekpack-blue\" />\n    </a>\n    <a href='https://github.com/psf/black'>\n        <img src='https://img.shields.io/badge/code%20style-black-000000.svg' alt='Code style: black' />\n    </a>\n    <a href=\"https://github.com/cthoyt/curies/blob/main/.github/CODE_OF_CONDUCT.md\">\n        <img src=\"https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg\" alt=\"Contributor Covenant\"/>\n    </a>\n    <a href=\"https://zenodo.org/badge/latestdoi/519905487\">\n        <img src=\"https://zenodo.org/badge/519905487.svg\" alt=\"DOI\">\n    </a>\n</p>\n\nIdiomatic conversion between URIs and compact URIs (CURIEs).\n\n```python\nimport curies\n\nconverter = curies.load_prefix_map({\n    \"CHEBI\": \"http://purl.obolibrary.org/obo/CHEBI_\",\n    # ... and so on\n})\n\n>>> converter.compress(\"http://purl.obolibrary.org/obo/CHEBI_1\")\n'CHEBI:1'\n\n>>> converter.expand(\"CHEBI:1\")\n'http://purl.obolibrary.org/obo/CHEBI_1'\n```\n\nFull documentation is available at [curies.readthedocs.io](https://curies.readthedocs.io).\n\n### CLI Usage\n\nThis package comes with a built-in CLI for running a resolver web application or a IRI mapper web application:\n\n```shell\n# Run a resolver\npython -m curies resolver --host 0.0.0.0 --port 8764 bioregistry\n\n# Run a mapper\npython -m curies mapper --host 0.0.0.0 --port 8764 bioregistry\n```\n\nThe positional argument can be one of the following:\n\n1. A pre-defined prefix map to get from the web (bioregistry, go, obo, monarch, prefixcommons)\n2. A local file path or URL to a prefix map, extended prefix map, or one of several formats. Requires specifying\n   a `--format`.\n\nThe framework can be swapped to use Flask (default) or FastAPI with `--framework`. The\nserver can be swapped to use Werkzeug (default) or Uvicorn with `--server`. These functionalities\nare also available programmatically, see the docs for more information.\n\n## \ud83e\uddd1\u200d\ud83e\udd1d\u200d\ud83e\uddd1 Related\n\nOther packages that convert between CURIEs and URIs:\n\n- https://github.com/prefixcommons/prefixcommons-py (Python)\n- https://github.com/prefixcommons/curie-util (Java)\n- https://github.com/geneontology/curie-util-py (Python)\n- https://github.com/geneontology/curie-util-es5 (Node.js)\n- https://github.com/endoli/curie.rs (Rust)\n- https://github.com/cthoyt/curies4j (Java)\n- https://github.com/biopragmatics/curies.rs (Rust, Node.js, Python)\n\n## \ud83d\ude80 Installation\n\nThe most recent release can be installed from\n[PyPI](https://pypi.org/project/curies/) with:\n\n```bash\n$ pip install curies\n```\n\nThis package currently supports both Pydantic v1 and v2. See the\n[Pydantic migration guide](https://docs.pydantic.dev/2.0/migration/)\nfor updating your code.\n\n## \ud83d\udc50 Contributing\n\nContributions, whether filing an issue, making a pull request, or forking, are appreciated. See\n[CONTRIBUTING.md](https://github.com/cthoyt/curies/blob/master/.github/CONTRIBUTING.md) for more information on getting\ninvolved.\n\n## \ud83d\udc4b Attribution\n\n### \ud83d\ude4f Acknowledgements\n\nThis package heavily builds on the [trie](https://en.wikipedia.org/wiki/Trie)\ndata structure implemented in [`pytrie`](https://github.com/gsakkis/pytrie).\n\n### \u2696\ufe0f License\n\nThe code in this package is licensed under the MIT License.\n\n### \ud83c\udf6a Cookiecutter\n\nThis package was created with [@audreyfeldroy](https://github.com/audreyfeldroy)'s\n[cookiecutter](https://github.com/cookiecutter/cookiecutter) package using [@cthoyt](https://github.com/cthoyt)'s\n[cookiecutter-snekpack](https://github.com/cthoyt/cookiecutter-snekpack) template.\n\n## \ud83d\udee0\ufe0f For Developers\n\n<details>\n  <summary>See developer instructions</summary>\n\n\nThe final section of the README is for if you want to get involved by making a code contribution.\n\n### Development Installation\n\nTo install in development mode, use the following:\n\n```bash\n$ git clone git+https://github.com/cthoyt/curies.git\n$ cd curies\n$ pip install -e .\n```\n\n### \ud83e\udd7c Testing\n\nAfter cloning the repository and installing `tox` with `pip install tox`, the unit tests in the `tests/` folder can be\nrun reproducibly with:\n\n```shell\n$ tox\n```\n\nAdditionally, these tests are automatically re-run with each commit in a [GitHub Action](https://github.com/cthoyt/curies/actions?query=workflow%3ATests).\n\n### \ud83d\udcd6 Building the Documentation\n\nThe documentation can be built locally using the following:\n\n```shell\n$ git clone git+https://github.com/cthoyt/curies.git\n$ cd curies\n$ tox -e docs\n$ open docs/build/html/index.html\n```\n\nThe documentation automatically installs the package as well as the `docs`\nextra specified in the [`setup.cfg`](setup.cfg). `sphinx` plugins\nlike `texext` can be added there. Additionally, they need to be added to the\n`extensions` list in [`docs/source/conf.py`](docs/source/conf.py).\n\n### \ud83d\udce6 Making a Release\n\nAfter installing the package in development mode and installing\n`tox` with `pip install tox`, the commands for making a new release are contained within the `finish` environment\nin `tox.ini`. Run the following from the shell:\n\n```shell\n$ tox -e finish\n```\n\nThis script does the following:\n\n1. Uses [Bump2Version](https://github.com/c4urself/bump2version) to switch the version number in the `setup.cfg`,\n   `src/curies/version.py`, and [`docs/source/conf.py`](docs/source/conf.py) to not have the `-dev` suffix\n2. Packages the code in both a tar archive and a wheel using [`build`](https://github.com/pypa/build)\n3. Uploads to PyPI using [`twine`](https://github.com/pypa/twine). Be sure to have a `.pypirc` file configured to avoid the need for manual input at this\n   step\n4. Push to GitHub. You'll need to make a release going with the commit where the version was bumped.\n5. Bump the version to the next patch. If you made big changes and want to bump the version by minor, you can\n   use `tox -e bumpversion minor` after.\n\n</details>\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Idiomatic conversion between URIs and compact URIs (CURIEs).",
    "version": "0.7.9",
    "project_urls": {
        "Bug Tracker": "https://github.com/cthoyt/curies/issues",
        "Download": "https://github.com/cthoyt/curies/releases",
        "Homepage": "https://github.com/cthoyt/curies",
        "Source Code": "https://github.com/cthoyt/curies"
    },
    "split_keywords": [
        "snekpack",
        " cookiecutter",
        " semantic web",
        " compact uniform resource identifiers",
        " uniform resource identifiers",
        " curies",
        " iris"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c8ce464bad6035f6d681485dc3534a5e5c5cd69615770a02bbd2572bc7cb362b",
                "md5": "36d6ca3b4817045cc9f84e78a08fe404",
                "sha256": "e4c5beb91642376953c94db0ee2fb5d2b011c3b16749516436114ba61442f260"
            },
            "downloads": -1,
            "filename": "curies-0.7.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "36d6ca3b4817045cc9f84e78a08fe404",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 45810,
            "upload_time": "2024-04-03T08:13:58",
            "upload_time_iso_8601": "2024-04-03T08:13:58.141472Z",
            "url": "https://files.pythonhosted.org/packages/c8/ce/464bad6035f6d681485dc3534a5e5c5cd69615770a02bbd2572bc7cb362b/curies-0.7.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "65d0143fa90df55e5e5b1a0408f43a2e84c7f76293083a7ba63546b33cff31f6",
                "md5": "ddf747be94cba1e2651edbb5a48bc151",
                "sha256": "3b63c5fea7b0e967629a3a384b1a8c59b56c503487c1dcbacddeab59e25db4d8"
            },
            "downloads": -1,
            "filename": "curies-0.7.9.tar.gz",
            "has_sig": false,
            "md5_digest": "ddf747be94cba1e2651edbb5a48bc151",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 241312,
            "upload_time": "2024-04-03T08:13:59",
            "upload_time_iso_8601": "2024-04-03T08:13:59.960460Z",
            "url": "https://files.pythonhosted.org/packages/65/d0/143fa90df55e5e5b1a0408f43a2e84c7f76293083a7ba63546b33cff31f6/curies-0.7.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-03 08:13:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cthoyt",
    "github_project": "curies",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "curies"
}
        
Elapsed time: 0.28593s