Skip to main content

pyDIGGS

PyPI version Python Versions Downloads Downloads/Month Build Status Documentation Status GitHub Issues License

A Python package for Data Interchange for Geotechnical and Geoenvironmental Specialists (DIGGS).

Project Lead

* Xin Peng (<xin_peng@outlook.com>)
* Asitha Senanayake (<asitha.senanayake@utexas.edu>)

Features

  • Validate DIGGS instance files against:
    • DIGGS XSD Schema (2.5.a, 2.6, 3.0.0) with namespace auto-detect (default profile 3.0.0 when the namespace is unknown)
    • DIGGS Standard dictionaries / codeSpace semantics (offline bundle from diggsml.org/def)
    • Schematron business rules (bundled DIGGS lxml-adapted rules by default)
    • Lightweight context checks (structure / SRS / xlink / dataBlock arity)
  • Flexible validation output:
    • Machine-readable findings with stable rule ids, lines, XPaths and gml:ids, as JSON (diggs-findings 1.0) or SARIF 2.1.0 (pydiggs validate, validate())
    • Write validation errors to log files
    • Print validation errors directly to console
  • Command-line interface (CLI) for easy integration
  • Use it from any application:
    • Python: validate() for files, validate_bytes() for uploads and other in-memory data
    • Web apps: an HTTP API with OpenAPI 3.1 (the server extra, then pydiggs serve --http, or mount pydiggs.server.create_router() in FastAPI)
    • Containers: that HTTP API as a non-root, attested image for amd64 and arm64, ghcr.io/xinp-hub/pydiggs:X.Y.Z (no latest tag)
    • Desktop and native apps: a stdio JSON-RPC 2.0 sidecar (pydiggs serve --stdio) that any host language can drive
    • AI assistants: an MCP server with read-only validation and rule tools (the mcp extra, then pydiggs serve --mcp)
    • Browsers: in a web page with Pyodide, so the file never leaves the user's machine (a dependency-free Web Worker example is in examples/browser-worker)

Security

pyDIGGS treats every DIGGS file as untrusted input. All XML is parsed with external entities, DTD loading and network access refused, so a file cannot make pyDIGGS read other local files or contact a server. There are two exceptions:

  • A codeSpace that points at a local dictionary (file:///, ./, ../). The DIGGS whitelist permits these, and pyDIGGS parses them with the same hardened settings.
  • With DictionarySemanticValidator(allow_network=True), which is off by default, pyDIGGS downloads dictionaries, but only from whitelisted http/https URLs, re-checked on every redirect, with time and size limits.

Schemas and Schematron rules are different: they are code, not data. A custom schema_path or schematron_path runs with your permissions (Schematron is compiled to XSLT, which can read local files), so only pass files you trust. The bundled DIGGS schemas and rules make no file or network access.

Log files are written to the working directory and are never written through a symlink. Vulnerabilities: please report them privately (see SECURITY.md).

Install from the PyPI wheels, which bundle libxml2, rather than building lxml against an older system libxml2.

Web Application

Not a Python user? Looking for leveraging the power of pyDIGGS in a modern web application? Check out:

Quick Start

Install pydiggs (requires Python 3.11+):

uv pip install pydiggs
# or: pip install pydiggs

Basic usage with Python:

from pydiggs import detect_diggs_version, validator

# Profile auto-detected from the instance namespace (unknown → 3.0.0)
validation = validator("path/to/your/diggs_file.xml")

print(detect_diggs_version("path/to/your/diggs_file.xml"))  # "2.5.a", "2.6", or "3.0.0"

# Or pin a profile explicitly (Python API only)
validation = validator("path/to/your/diggs_file.xml", diggs_version="2.6")

# Schema validation
validation.schema_check()

# Dictionary validation (DIGGSml semantic checks; offline dictionaries)
validation.dictionary_check()

# Schematron validation (bundled DIGGS rules by default)
validation.schematron_check()

# Context checks
validation.context_check()

# Or supply a custom Schematron file
validation = validator("path/to/your/diggs_file.xml", schematron_path="path/to/schematron.sch")
validation.schematron_check()

Every check at once, as machine-readable findings:

# JSON (diggs-findings 1.0); exit 0 = no errors, 1 = errors, 2 = usage/unreadable input
pydiggs validate --format json "path/to/your/diggs_file.xml"

# A whole folder as SARIF 2.1.0 for code-scanning tools
pydiggs validate --format sarif --output pydiggs.sarif "path/to/folder"
from pydiggs import validate

report = validate("path/to/your/diggs_file.xml")  # prints nothing, writes no files
print(report.ok, report.counts)
for finding in report.findings:
    print(finding.rule_id, finding.severity, finding.line, finding.xpath)

See findings for the format, rule ids, exit codes and privacy defaults (no snippets, no absolute paths).

Basic usage with CLI:

# Schema validation (auto-detects DIGGS 2.5.a / 2.6 / 3.0.0)
pydiggs schema_check "path/to/your/diggs_file.xml"

# Dictionary validation
pydiggs dictionary_check "path/to/your/diggs_file.xml"

# Schematron validation (bundled rules)
pydiggs schematron_check "path/to/your/diggs_file.xml"

# Context validation
pydiggs context_check "path/to/your/diggs_file.xml"

# Custom Schematron
pydiggs schematron_check "path/to/your/diggs_file.xml" --schematron_path "path/to/schematron.sch"

See usage for diggs_version / schema_path overrides, log output options, and known limits (dictionary check 12 as WARNING, bundled Schematron subset, and more).

For more detailed information and advanced usage, please see the documentation.

Metadata

Release files for pydiggs 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydiggs 1.4.0
File Size Uploaded Provenance Actions
pydiggs-1.4.0.tar.gz 2.8 MB With provenance Details for pydiggs-1.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pydiggs 1.4.0
File Interpreter ABI Platform Actions
pydiggs-1.4.0-py3-none-any.whl Python 3 none any Details for pydiggs-1.4.0-py3-none-any.whl

Total release size: 4.3 MB

Release files / pydiggs-1.4.0.tar.gz

Download URL pydiggs-1.4.0.tar.gz
Size 2.8 MB
Tags Source
SHA-256 checksum
How to use checksums
19a87144714c8a83e4d030b6146dc59a72c7086f2e65b167d9cdc2a72794389e
BLAKE2b-256 checksum
How to use checksums
0196b48cd72cbee2a0a6f189e14a8f2781992e10caaeabe2a9bf80843bbee54c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / pydiggs-1.4.0-py3-none-any.whl

Download URL pydiggs-1.4.0-py3-none-any.whl
Size 1.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
211c8b65bcb9a3fb99449c71c156da4bd1a193584c0051b710d2d196bb8c5158
BLAKE2b-256 checksum
How to use checksums
74bbc6f16d6852b40a90ac21b74a3162926735021792526b02fcdc028b862df6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Security for pydiggs 1.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pydiggs-1.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.4.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page