"""VCARD vocabulary using Pydantic RDF models.
This module provides Pydantic-based models for the vCard ontology,
allowing easy serialization to and from RDF formats.
References:
- https://www.w3.org/TR/vcard-rdf/
- https://www.w3.org/2006/vcard/ns
"""
from __future__ import annotations
from typing import Annotated, ClassVar
from rdflib import Namespace, URIRef
from ._base import LocalizedStr, RdfBaseModel, RdfProperty
# VCARD namespace (not built-in to rdflib)
VCARD = Namespace("http://www.w3.org/2006/vcard/ns#")
[docs]
class VcardResource(RdfBaseModel):
"""Base class for vCard resources."""
rdf_namespace: ClassVar = VCARD
rdf_prefixes: ClassVar = {"vcard": VCARD}
[docs]
class VCard(VcardResource):
"""A vCard - electronic business card."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.VCard)
# Identification
fn: Annotated[
LocalizedStr | None,
RdfProperty(VCARD.fn),
] = None # Formatted name
n: Annotated[str | URIRef | Name | list[str | URIRef | Name] | None, RdfProperty(VCARD.n)] = None # Name
nickname: Annotated[
LocalizedStr | None,
RdfProperty(VCARD.nickname),
] = None
# Delivery address
adr: Annotated[str | URIRef | Address | list[str | URIRef | Address] | None, RdfProperty(VCARD.adr)] = None
# Telecommunications
tel: Annotated[str | URIRef | Telephone | list[str | URIRef | Telephone] | None, RdfProperty(VCARD.tel)] = None
email: Annotated[str | URIRef | Email | list[str | URIRef | Email] | None, RdfProperty(VCARD.email)] = None
# Organization
org: Annotated[str | URIRef | Organization | list[str | URIRef | Organization] | None, RdfProperty(VCARD.org)] = (
None
)
organization_name: Annotated[
LocalizedStr | None,
RdfProperty(VCARD["organization-name"]),
] = None
organization_unit: Annotated[
LocalizedStr | None,
RdfProperty(VCARD["organization-unit"]),
] = None
# Title and role
title: Annotated[
LocalizedStr | None,
RdfProperty(VCARD.title),
] = None
role: Annotated[
LocalizedStr | None,
RdfProperty(VCARD.role),
] = None
# Online presence
url: Annotated[str | URIRef | list[str | URIRef] | None, RdfProperty(VCARD.url)] = None
# Birthday
bday: Annotated[str | list[str] | None, RdfProperty(VCARD.bday)] = None
# Photo
photo: Annotated[str | URIRef | list[str | URIRef] | None, RdfProperty(VCARD.photo)] = None
logo: Annotated[str | URIRef | list[str | URIRef] | None, RdfProperty(VCARD.logo)] = None
# Categories
category: Annotated[
LocalizedStr | None,
RdfProperty(VCARD.category),
] = None
# Notes
note: Annotated[
LocalizedStr | None,
RdfProperty(VCARD.note),
] = None
# Revision
rev: Annotated[str | list[str] | None, RdfProperty(VCARD.rev)] = None
# UID
uid: Annotated[str | URIRef | list[str | URIRef] | None, RdfProperty(VCARD.uid)] = None
# Language
language: Annotated[str | list[str] | None, RdfProperty(VCARD.language)] = None
# New properties
has_gender: Annotated[str | URIRef | Gender | list[str | URIRef | Gender] | None, RdfProperty(VCARD.hasGender)] = (
None
)
has_related: Annotated[
str | URIRef | Related | list[str | URIRef | Related] | None, RdfProperty(VCARD.hasRelated)
] = None
has_geo: Annotated[str | URIRef | Location | list[str | URIRef | Location] | None, RdfProperty(VCARD.hasGeo)] = None
has_sound: Annotated[str | URIRef | list[str | URIRef] | None, RdfProperty(VCARD.hasSound)] = None
has_key: Annotated[str | URIRef | list[str | URIRef] | None, RdfProperty(VCARD.hasKey)] = None
has_logo: Annotated[str | URIRef | list[str | URIRef] | None, RdfProperty(VCARD.hasLogo)] = None
has_photo: Annotated[str | URIRef | list[str | URIRef] | None, RdfProperty(VCARD.hasPhoto)] = None
has_url: Annotated[str | URIRef | list[str | URIRef] | None, RdfProperty(VCARD.hasUrl)] = None
has_email: Annotated[str | URIRef | Email | list[str | URIRef | Email] | None, RdfProperty(VCARD.hasEmail)] = None
has_telephone: Annotated[
str | URIRef | Telephone | list[str | URIRef | Telephone] | None, RdfProperty(VCARD.hasTelephone)
] = None
has_note: Annotated[
LocalizedStr | None,
RdfProperty(VCARD.hasNote),
] = None
has_uid: Annotated[str | URIRef | list[str | URIRef] | None, RdfProperty(VCARD.hasUID)] = None
has_language: Annotated[str | list[str] | None, RdfProperty(VCARD.hasLanguage)] = None
[docs]
class Individual(VCard):
"""An individual person."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.Individual)
[docs]
class Group(VCard):
"""A group of persons or entities."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.Group)
has_member: Annotated[str | URIRef | VCard | list[str | URIRef | VCard] | None, RdfProperty(VCARD.hasMember)] = None
[docs]
class Organization(VCard):
"""An organization."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.Organization)
[docs]
class Location(VCard):
"""A location."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.Location)
[docs]
class Name(VcardResource):
"""A name component."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.Name)
family_name: Annotated[
LocalizedStr | None,
RdfProperty(VCARD["family-name"]),
] = None
given_name: Annotated[
LocalizedStr | None,
RdfProperty(VCARD["given-name"]),
] = None
additional_name: Annotated[
LocalizedStr | None,
RdfProperty(VCARD["additional-name"]),
] = None
honorific_prefix: Annotated[
LocalizedStr | None,
RdfProperty(VCARD["honorific-prefix"]),
] = None
honorific_suffix: Annotated[
LocalizedStr | None,
RdfProperty(VCARD["honorific-suffix"]),
] = None
[docs]
class Address(VcardResource):
"""A delivery address."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.Address)
street_address: Annotated[
LocalizedStr | None,
RdfProperty(VCARD["street-address"]),
] = None
locality: Annotated[
LocalizedStr | None,
RdfProperty(VCARD.locality),
] = None
region: Annotated[
LocalizedStr | None,
RdfProperty(VCARD.region),
] = None
postal_code: Annotated[str | list[str] | None, RdfProperty(VCARD["postal-code"])] = None
country_name: Annotated[
LocalizedStr | None,
RdfProperty(VCARD["country-name"]),
] = None
post_office_box: Annotated[str | list[str] | None, RdfProperty(VCARD["post-office-box"])] = None
extended_address: Annotated[
LocalizedStr | None,
RdfProperty(VCARD["extended-address"]),
] = None
[docs]
class Telephone(VcardResource):
"""A telephone number."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.Telephone)
has_value: Annotated[str | URIRef | list[str | URIRef] | None, RdfProperty(VCARD.hasValue)] = None
[docs]
class Email(VcardResource):
"""An email address."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.Email)
has_value: Annotated[str | URIRef | list[str | URIRef] | None, RdfProperty(VCARD.hasValue)] = None
__all__ = [
"VcardResource",
"VCard",
"Individual",
"Group",
"Organization",
"Location",
"Name",
"Address",
"Telephone",
"Email",
"TelephoneType",
"EmailType",
"AddressType",
"Gender",
"Related",
"Acquaintance",
"Friend",
"Parent",
"Child",
"Spouse",
"Sibling",
"Kin",
"Colleague",
"Emergency",
"Agent",
"CoResident",
"Neighbor",
"Coworker",
"Kind",
"Type",
]
[docs]
class TelephoneType(VcardResource):
"""Telephone type classifications."""
pass
[docs]
class EmailType(VcardResource):
"""Email type classifications."""
pass
[docs]
class AddressType(VcardResource):
"""Address type classifications."""
pass
[docs]
class Gender(VcardResource):
"""A gender."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.Gender)
sex: Annotated[
LocalizedStr | None,
RdfProperty(VCARD.sex),
] = None
identity: Annotated[
LocalizedStr | None,
RdfProperty(VCARD.identity),
] = None
[docs]
class Acquaintance(Related):
"""An acquaintance."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.Acquaintance)
[docs]
class Friend(Related):
"""A friend."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.Friend)
[docs]
class Parent(Related):
"""A parent."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.Parent)
[docs]
class Child(Related):
"""A child."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.Child)
[docs]
class Spouse(Related):
"""A spouse."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.Spouse)
[docs]
class Sibling(Related):
"""A sibling."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.Sibling)
[docs]
class Kin(Related):
"""A kin."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.Kin)
[docs]
class Colleague(Related):
"""A colleague."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.Colleague)
[docs]
class Emergency(Related):
"""An emergency contact."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.Emergency)
[docs]
class Agent(Related):
"""An agent."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.Agent)
[docs]
class CoResident(Related):
"""A co-resident."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.CoResident)
[docs]
class Neighbor(Related):
"""A neighbor."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.Neighbor)
[docs]
class Coworker(Related):
"""A coworker."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.Coworker)
[docs]
class Kind(VcardResource):
"""A kind of vCard."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.Kind)
[docs]
class Type(VcardResource):
"""A property type."""
rdf_type: ClassVar[str | URIRef | None] = str(VCARD.Type)