Skip to main content

CQL (Contextual Query Language) Parser (for Python)

cql-parser @ PyPI Github Actions: Python package


Notice

Prefix parsing and resolution is still work-in-progress! Test cases mostly check out but it definitely needs to be finished before using in real world scenarios.

Requires

Building

# see: https://setuptools.pypa.io/en/latest/build_meta.html
python3 -m pip install -q build
python3 -m build

Install

# built package
python3 -m pip install dist/cql_parser-<version>-py2.py3-none-any.whl
# or
python3 -m pip install dist/cql-parser-<version>.tar.gz

# for local development
python3 -m pip install -e .[test]

Usage

Really quick:

import cql

print(cql.parse("dc.title any fish").toXCQLString(pretty=True))

A bit more involved:

import logging
logging.basicConfig(level=logging.DEBUG)

from cql.parser import CQLParser12

# use CQL version 1.2 parser
cqlparser = CQLParser12()
query = cqlparser.run("dc.title any fish")
# do something with the output
print(query.toCQL())
print(query.toXCQLString(pretty=True))

A for a deeper dive, take a look at src/cql/__init__.py or the various test files in tests/.

Development

  • Uses pytest (with coverage, clarity and randomly plugins).
  • See test files in tests/ folder. The regression test files are a copy from indexdata/cql-java and are not included in the built package. The XCQL serialization differs slightly from the only CQL Python 'library' I could find.
  • As for changing the lexer or parser, see ply docs.

Run all tests with:

# install test dependencies
python3 -m install -e .[test]
# run
pytest

Run style checks:

python3 -m pip install -e .[style]
black --check .
flake8 . --show-source --statistics
isort --check --diff .

# building the package:
python3 -m pip install -e .[build]
python3 -m build
twine check --strict dist/*

Vendor dependencies:

python3 -m pip install -e .[vendor]
vendoring sync
# NOTE: some changes still not automated ...
git checkout -- src/cql/_vendor/ply/LICENSE

See also

Metadata

Release files for cql-parser 1.0.2

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

Source distribution (sdist)

Source distribution for cql-parser 1.0.2
File Size Uploaded Provenance
cql-parser-1.0.2.tar.gz 48.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for cql-parser 1.0.2
File Interpreter ABI Platform
cql_parser-1.0.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 92.3 kB

Release files / cql-parser-1.0.2.tar.gz

Download URL cql-parser-1.0.2.tar.gz
Size 48.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c5b827add9f3753baac88450e88cce9fe99e999b7f01dcfb33edf81050a61f37
BLAKE2b-256 checksum
How to use checksums
906a41d59a65d3411017ee1ad222066b612a1cf755fb03dda8ca7771ea3e6e80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release files / cql_parser-1.0.2-py2.py3-none-any.whl

Download URL cql_parser-1.0.2-py2.py3-none-any.whl
Size 43.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
23710186e7f5a4485dcb66ba69aab6f54fa71ff63230218a4d51ae53af75b3c7
BLAKE2b-256 checksum
How to use checksums
3a46373047b976d06ce5e0cb9de1466ab4358e67769729994caa4cab4ef79094
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Security for cql-parser 1.0.2

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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