Skip to main content

A Python library for working with CITE architecture URNs for scholarly citation.

Project description

urn_citation

A Python library for working with CITE architecture URNs for scholarly citation.

Overview

urn_citation provides Pydantic-based models for representing and parsing Uniform Resource Names (URNs) defined for the CITE architecture. The current release supports Canonical Text Service (CTS) URNs, which are used to identify passages of canonically citable texts with hierarchical work and passage components.

Features

  • Pydantic Models: Type-safe URN representations with validation
  • CTS URN Support: Full support for parsing and creating Canonical Text Service URNs
  • Flexible Parsing: Parse CTS URN strings into structured objects
  • Optional Fields: Support for optional work, version, exemplar, and passage components

Installation

pip install urn-citation

Quick Start

Creating a CTS URN

from urn_citation import CtsUrn

# Create a CTS URN with required fields
urn = CtsUrn(
    urn_type="cts",
    namespace="greekLit",
    text_group="tlg0012"
)

# Create a CTS URN with all fields
urn_full = CtsUrn(
    urn_type="cts",
    namespace="greekLit",
    text_group="tlg0012",
    work="001",
    version="wacl1",
    exemplar="ex1",
    passage="1.1-1.5"
)

Parsing from a String

# Parse a CTS URN from a colon-delimited string
urn_string = "urn:cts:greekLit:tlg0012.001.wacl1:1.1-1.5"
urn = CtsUrn.from_string(urn_string)

print(urn.text_group)  # "tlg0012"
print(urn.work)        # "001"
print(urn.version)     # "wacl1"
print(urn.passage)     # "1.1-1.5"

Serialization

# Convert to dictionary
urn_dict = urn.model_dump()

# Convert to JSON
urn_json = urn.model_dump_json()

CTS URN Structure

A CTS URN follows the format:

urn:cts:<namespace>:<work_component>:<passage_component>

Where:

  • namespace: The namespace defining the text collection (e.g., "greekLit", "latinLit")
  • work_component: One to four dot-delimited identifiers for text group, work, version, and exemplar
  • passage_component: Optional passage reference, may contain a single passage or range (with hyphen)

License

See the LICENSE file for details.

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

urn_citation-0.5.0.tar.gz (52.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

urn_citation-0.5.0-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

Details for the file urn_citation-0.5.0.tar.gz.

File metadata

  • Download URL: urn_citation-0.5.0.tar.gz
  • Upload date:
  • Size: 52.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for urn_citation-0.5.0.tar.gz
Algorithm Hash digest
SHA256 c9de26c3a7cb9d746ea047e1d80b9fbb0f7e520c2c7a543ff4032b4edaa30775
MD5 8a950e424e3ea318dd9e7bb9c23e5665
BLAKE2b-256 74e025cbd0dd4667a1709be565f5e67eeb01a49578555fda1df4e712f89f1633

See more details on using hashes here.

Provenance

The following attestation bundles were made for urn_citation-0.5.0.tar.gz:

Publisher: publish.yml on neelsmith/urn_citation

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file urn_citation-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: urn_citation-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 20.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for urn_citation-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 77dfdc9c7b097db391f6390e67304703573ee6eae76e660cb3abba8b3ad30d97
MD5 a7cd120b6fe98b835e85d6550aeab8ed
BLAKE2b-256 463c8170a62a7270f2e76d0434dc0e17c73c0e1f102c3df74229d1b2ead44b08

See more details on using hashes here.

Provenance

The following attestation bundles were made for urn_citation-0.5.0-py3-none-any.whl:

Publisher: publish.yml on neelsmith/urn_citation

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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