Skip to main content

Utility functions to interact with handle.net API

Project description

flake8 Lint Test codecov PyPI version

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

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

acdh-handle-pyutils-0.4.2.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

acdh_handle_pyutils-0.4.2-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file acdh-handle-pyutils-0.4.2.tar.gz.

File metadata

  • Download URL: acdh-handle-pyutils-0.4.2.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for acdh-handle-pyutils-0.4.2.tar.gz
Algorithm Hash digest
SHA256 e829eddd6ce823547b5f6c0958b9baf676006bf00f36c389937f136c65d72388
MD5 2c6beea40ebf530bc667399b0209d976
BLAKE2b-256 75aacc6bb825de7b00d02d65e2b728b42ccbebd9a57d8f7484f4a599d63ed517

See more details on using hashes here.

File details

Details for the file acdh_handle_pyutils-0.4.2-py3-none-any.whl.

File metadata

File hashes

Hashes for acdh_handle_pyutils-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 50160301dc175bd0563974176785abbab561999f210f2533b4d83f4e175850a0
MD5 921287ad99133554953a8fe0aa866db0
BLAKE2b-256 e08a62d073b60af969d0e1c4d453efff16a759a888928b90e6277ac9cf41569d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page