ALEA Dublin Core Metadata library with zero dependencies
Project description
alea-dublincore
Description
alea-dublincore is a Python library for working with Dublin Core metadata. It provides a DublinCoreDocument class that allows you to create, manipulate, and serialize Dublin Core metadata in various formats, including JSON, JSON-LD, XML, and RDF.
In addition to DC metadata, the DublinCoreDocument class also supports:
- generating UUIDv4 IDs
- storing and serializing the full text content of a document, including its size, BLAKE2b hash, and raw bytes.
- base64 encoding and zlib/lzma serialization of the content for efficient storage and transmission
Installation
pip install alea-dublincore
Examples
Creating a Dublin Core Document
from alea_dublincore import DublinCoreDocument
import datetime
doc = DublinCoreDocument(
title="Sample Document",
creator=["John Doe", "Jane Smith"],
date=datetime.datetime(2023, 5, 1, 12, 0, 0),
subject=["Metadata", "Dublin Core"],
description="A sample document demonstrating the use of alea-dublincore",
language="en"
)
Storing and Loading From JSON, JSON-LD, XML, and RDF
# To JSON
json_str = doc.to_json()
print(json_str)
# To JSON-LD
json_ld_str = doc.to_json_ld()
print(json_ld_str)
# To XML
xml_str = doc.to_xml()
print(xml_str)
# To RDF
rdf_str = doc.to_rdf()
print(rdf_str)
# From JSON
doc_from_json = DublinCoreDocument.from_json(json_str)
# From JSON-LD
doc_from_json_ld = DublinCoreDocument.from_json_ld(json_ld_str)
# From XML
doc_from_xml = DublinCoreDocument.from_xml(xml_str)
# From RDF
doc_from_rdf = DublinCoreDocument.from_rdf(rdf_str)
# Check if the deserialized documents are equal to the original document
doc.content = b"This is the full text content of the document."
encoded_doc = doc.to_json() # Content will be base64 encoded and compressed
# Later, when deserializing
decoded_doc = DublinCoreDocument.from_json(encoded_doc)
print(decoded_doc.content.decode()) # Prints the original content
License
This ALEA project is released under the MIT License. See the LICENSE file for details.
Support
If you encounter any issues or have questions about using this ALEA project, please open an issue on GitHub.
Learn More
To learn more about ALEA and its software and research projects, visit the ALEA website.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file alea_dublincore-0.1.0.tar.gz.
File metadata
- Download URL: alea_dublincore-0.1.0.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.8.0-44-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfe732ab33297fad1310f92df79d55f197e7cc6869835387364fd9578c1c8104
|
|
| MD5 |
364c2413ae312dafef8afff58cfc0fe8
|
|
| BLAKE2b-256 |
f921523e5af6cc367d6635f8eb594672a13af372027d68df7552d33006203c5d
|
File details
Details for the file alea_dublincore-0.1.0-py3-none-any.whl.
File metadata
- Download URL: alea_dublincore-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.8.0-44-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55a7b20bfd7e13329f45bd0b379181e16ee416bf8d359fa75536be0cef9da634
|
|
| MD5 |
41294990c0caa1bb9a2336763c2075a2
|
|
| BLAKE2b-256 |
5a90a3ebcfc078d37ecbb88cd2d2901ef3521a22f75d318a66e135c00e49704e
|