[![flake8 Lint](https://github.com/acdh-oeaw/acdh-handle-pyutils/actions/workflows/lint.yml/badge.svg)](https://github.com/acdh-oeaw/acdh-handle-pyutils/actions/workflows/lint.yml)
[![Test](https://github.com/acdh-oeaw/acdh-handle-pyutils/actions/workflows/test.yml/badge.svg)](https://github.com/acdh-oeaw/acdh-handle-pyutils/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/acdh-oeaw/acdh-handle-pyutils/branch/master/graph/badge.svg?token=96XqlDbpDw)](https://codecov.io/gh/acdh-oeaw/acdh-handle-pyutils)
[![PyPI version](https://badge.fury.io/py/acdh-handle-pyutils.svg)](https://badge.fury.io/py/acdh-handle-pyutils)
# acdh-handle-pyutils
Utility functions to interact with handle.net API
## install
`pip install acdh-handle-pyutils`
## how to use
see `./tests/test_client.py` and also checkout the provided defaults for `acdh_handle_pyutils.client.HandleClient`
### register handle for url
```Python
import os
from acdh_handle_pyutils.client import HandleClient
HANDLE_USERNAME = os.environ.get("HANDLE_USERNAME")
HANDLE_PASSWORD = os.environ.get("HANDLE_PASSWORD")
URL_TO_REGISTER = "https://id.hansi4ever.com/123"
cl = HandleClient(HANDLE_USERNAME, HANDLE_PASSWORD)
result = cl.register_handle(URL_TO_REGISTER, full_url=True)
print(result)
# https://hdl.handle.net/21.11115/0000-000F-743B-D
```
Be aware that it might take a while until the registerd handle resolves
### update handle
```Python
import os
from acdh_handle_pyutils.client import HandleClient
HANDLE_USERNAME = os.environ.get("HANDLE_USERNAME")
HANDLE_PASSWORD = os.environ.get("HANDLE_PASSWORD")
HANDLE_TO_UPDATE = "https://hdl.handle.net/21.11115/0000-000F-743B-D"
URL_TO_UPDATE = "https://sumsi.com/is-the-best"
cl = HandleClient(HANDLE_USERNAME, HANDLE_PASSWORD)
updated = cl.update_handle(HANDLE_TO_UPDATE, URL_TO_UPDATE)print(result)
print(updated.status_code) # should return for `204 No Content` HTTP response code for a successful update
# 204
```
Be aware that it might take until the handle is actually updated by the handle service provider
Raw data
{
"_id": null,
"home_page": "https://github.com/acdh-oeaw/acdh-handle-pyutils",
"name": "acdh-handle-pyutils",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "acdh-handle-pyutils",
"author": "Peter Andorfer",
"author_email": "peter.andorfer@oeaw.ac.at",
"download_url": "https://files.pythonhosted.org/packages/75/aa/cc6bb825de7b00d02d65e2b728b42ccbebd9a57d8f7484f4a599d63ed517/acdh-handle-pyutils-0.4.2.tar.gz",
"platform": null,
"description": "[![flake8 Lint](https://github.com/acdh-oeaw/acdh-handle-pyutils/actions/workflows/lint.yml/badge.svg)](https://github.com/acdh-oeaw/acdh-handle-pyutils/actions/workflows/lint.yml)\n[![Test](https://github.com/acdh-oeaw/acdh-handle-pyutils/actions/workflows/test.yml/badge.svg)](https://github.com/acdh-oeaw/acdh-handle-pyutils/actions/workflows/test.yml)\n[![codecov](https://codecov.io/gh/acdh-oeaw/acdh-handle-pyutils/branch/master/graph/badge.svg?token=96XqlDbpDw)](https://codecov.io/gh/acdh-oeaw/acdh-handle-pyutils)\n[![PyPI version](https://badge.fury.io/py/acdh-handle-pyutils.svg)](https://badge.fury.io/py/acdh-handle-pyutils)\n\n# acdh-handle-pyutils\n\nUtility functions to interact with handle.net API\n\n## install\n\n`pip install acdh-handle-pyutils`\n\n\n## how to use\n\nsee `./tests/test_client.py` and also checkout the provided defaults for `acdh_handle_pyutils.client.HandleClient` \n\n### register handle for url\n\n```Python\nimport os\nfrom acdh_handle_pyutils.client import HandleClient\n\n\nHANDLE_USERNAME = os.environ.get(\"HANDLE_USERNAME\")\nHANDLE_PASSWORD = os.environ.get(\"HANDLE_PASSWORD\")\nURL_TO_REGISTER = \"https://id.hansi4ever.com/123\"\n\ncl = HandleClient(HANDLE_USERNAME, HANDLE_PASSWORD)\nresult = cl.register_handle(URL_TO_REGISTER, full_url=True)\nprint(result)\n# https://hdl.handle.net/21.11115/0000-000F-743B-D\n```\n\nBe aware that it might take a while until the registerd handle resolves\n\n### update handle\n\n\n```Python\nimport os\nfrom acdh_handle_pyutils.client import HandleClient\n\n\nHANDLE_USERNAME = os.environ.get(\"HANDLE_USERNAME\")\nHANDLE_PASSWORD = os.environ.get(\"HANDLE_PASSWORD\")\nHANDLE_TO_UPDATE = \"https://hdl.handle.net/21.11115/0000-000F-743B-D\"\nURL_TO_UPDATE = \"https://sumsi.com/is-the-best\"\n\n\ncl = HandleClient(HANDLE_USERNAME, HANDLE_PASSWORD)\nupdated = cl.update_handle(HANDLE_TO_UPDATE, URL_TO_UPDATE)print(result)\n\nprint(updated.status_code) # should return for `204 No Content` HTTP response code for a successful update\n# 204\n```\n\nBe aware that it might take until the handle is actually updated by the handle service provider\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Utility functions to interact with handle.net API",
"version": "0.4.2",
"split_keywords": [
"acdh-handle-pyutils"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e08a62d073b60af969d0e1c4d453efff16a759a888928b90e6277ac9cf41569d",
"md5": "921287ad99133554953a8fe0aa866db0",
"sha256": "50160301dc175bd0563974176785abbab561999f210f2533b4d83f4e175850a0"
},
"downloads": -1,
"filename": "acdh_handle_pyutils-0.4.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "921287ad99133554953a8fe0aa866db0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 4729,
"upload_time": "2022-09-26T08:22:54",
"upload_time_iso_8601": "2022-09-26T08:22:54.762764Z",
"url": "https://files.pythonhosted.org/packages/e0/8a/62d073b60af969d0e1c4d453efff16a759a888928b90e6277ac9cf41569d/acdh_handle_pyutils-0.4.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "75aacc6bb825de7b00d02d65e2b728b42ccbebd9a57d8f7484f4a599d63ed517",
"md5": "2c6beea40ebf530bc667399b0209d976",
"sha256": "e829eddd6ce823547b5f6c0958b9baf676006bf00f36c389937f136c65d72388"
},
"downloads": -1,
"filename": "acdh-handle-pyutils-0.4.2.tar.gz",
"has_sig": false,
"md5_digest": "2c6beea40ebf530bc667399b0209d976",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 4773,
"upload_time": "2022-09-26T08:22:56",
"upload_time_iso_8601": "2022-09-26T08:22:56.025089Z",
"url": "https://files.pythonhosted.org/packages/75/aa/cc6bb825de7b00d02d65e2b728b42ccbebd9a57d8f7484f4a599d63ed517/acdh-handle-pyutils-0.4.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-09-26 08:22:56",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "acdh-oeaw",
"github_project": "acdh-handle-pyutils",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"requirements": [],
"lcname": "acdh-handle-pyutils"
}