Skip to main content

The Python bindings of the official CityJSON validator

Project description

cjvalpy

GitHub license PyPI version

Python bindings of cjval, the official validator for CityJSON files.

Installation

pip

To install the latest release: pip install cjvalpy

If you want to compile it yourself

  1. install latest Rust
  2. install maturin
  3. maturin build --release
  4. cd ./target/wheels/
  5. pip install [name-wheel].whl will install it to your local Python

Development

  1. install Rust (v1.39+)
  2. install maturin
  3. maturin develop
  4. move to another folder, and import cjvalpy shouldn't return any error

Usage

Made to be used with cjio:

cjio myfile.city.json validate

but can be used directly in python:

import cjvalpy
import json
import urllib.request

f = open("~/data/noise.city.json")
fj = json.loads(f.read())
js = []
js.append(json.dumps(fj))
print("Downloading the Extension JSON schema file(s):")
if "extensions" in fj:
    for ext in fj["extensions"]:
        theurl = fj["extensions"][ext]["url"]
        try:
            with urllib.request.urlopen(fj["extensions"][ext]["url"]) as f:
                sf = f.read().decode('utf-8')
                js.append(sf)
        except:
            s = "'%s' cannot be downloaded\nAbort" % fj["extensions"][ext]["url"]
            raise Exception(s)
val = cjvalpy.CJValidator(js)
val.validate()
re = val.get_report()
print(val.get_report())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

cjvalpy-0.4.1-cp311-none-win_amd64.whl (1.3 MB view hashes)

Uploaded CPython 3.11 Windows x86-64

cjvalpy-0.4.1-cp311-cp311-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (2.6 MB view hashes)

Uploaded CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

cjvalpy-0.4.1-cp310-none-win_amd64.whl (1.3 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

cjvalpy-0.4.1-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (2.6 MB view hashes)

Uploaded CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

cjvalpy-0.4.1-cp39-none-win_amd64.whl (1.3 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

cjvalpy-0.4.1-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (2.6 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

cjvalpy-0.4.1-cp38-none-win_amd64.whl (1.3 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

cjvalpy-0.4.1-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (2.6 MB view hashes)

Uploaded CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

Supported by

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