Skip to main content

An unofficial implementation of the Camtrap DP 1.0.2 datapackage standard with explicit Python dataclasses and pydantic. Intended to help developers with exporting their data to the Camtrap DP 1.0.2 datapackage format.

Project description

PyPI version Python Versions CI Status Code style: ruff License: MIT

trap-schema

An unofficial, strictly-typed implementation of the Camtrap DP 1.0.2 datapackage standard.

trap-schema uses Python dataclasses and Pydantic to provide robust, schema-aware data structures. It is designed to help developers easily parse, validate, and export camera trap data into the official Frictionless Data format without second-guessing schema constraints or having the documentation open on a second monitor.

Features

  • Strict Validation: Built on pydantic to enforce constraints (e.g., coordinate bounds, unique IDs, valid media types) at instantiation.
  • Ergonomic Tables: Treat tabular data natively. Tables act as columnar data structures but guarantee per-row validation.
  • Auto-Synced Documentation: Docstrings and schema attributes are automatically kept in sync with the official Camtrap DP JSON Schemas using a custom AST transformer.

Installation

This project uses uv for fast and reliable package management.

To add trap-schema to your project:

uv add trap-schema

Quick Start

from trap_schema.tables import DeploymentRow, DeploymentTable

# 1. Create validated rows
deployment = DeploymentRow(
    deploymentID="dep_001",
    latitude=56.2,
    longitude=10.4,
    deploymentStart="2026-04-25T10:00:00Z",
    deploymentEnd="2026-05-25T10:00:00Z",
)

# 2. Group into a Table (validates unique keys and types)
table = DeploymentTable(rows=[deployment])

# 3. Export to Camtrap DP standard CSV
table.save("out_dir")

Development

git clone https://github.com/asgersvenning/trap-schema.git
cd trap-schema
uv sync --all-groups

Update docstrings

We use libcst and frictionless to seamlessly and automatically integrate the official docstrings for table and metadata fields.

To update these run:

uv run tools/docstrings.py

Linting

[uv] ruff check --ignore E501

Testing

uv run pytest tests

License

MIT

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

trap_schema-0.1.1.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

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

trap_schema-0.1.1-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file trap_schema-0.1.1.tar.gz.

File metadata

  • Download URL: trap_schema-0.1.1.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for trap_schema-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6db1444cdaecc336cf2306de7717297798396e5f2ea987e2b4af801e6f824017
MD5 77d5baa1c76f4cf2a8b03796fbf26b4a
BLAKE2b-256 3f42f61bcd5e0ebc98e8aeceddca3e92b56b4c6fd06d591d4d6bcebe10b90095

See more details on using hashes here.

File details

Details for the file trap_schema-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: trap_schema-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for trap_schema-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 da9577fd33b7786644e25b38a3b8702a130192651b26ccfe3b00df274b6ac3ad
MD5 d95cb12b31275de40c5573482787b162
BLAKE2b-256 296d88fd52163363e63cdb462a847ab920a7cf77d08dd09db75cd40cf472987d

See more details on using hashes here.

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