Skip to main content

"CQL (Contextual Query Language) Parser"

Project description

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

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

cql-parser-1.0.2.tar.gz (48.7 kB view details)

Uploaded Source

Built Distribution

cql_parser-1.0.2-py2.py3-none-any.whl (43.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file cql-parser-1.0.2.tar.gz.

File metadata

  • Download URL: cql-parser-1.0.2.tar.gz
  • Upload date:
  • Size: 48.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for cql-parser-1.0.2.tar.gz
Algorithm Hash digest
SHA256 c5b827add9f3753baac88450e88cce9fe99e999b7f01dcfb33edf81050a61f37
MD5 c8552aea7d03eb413f2eb3c81e14fce5
BLAKE2b-256 906a41d59a65d3411017ee1ad222066b612a1cf755fb03dda8ca7771ea3e6e80

See more details on using hashes here.

File details

Details for the file cql_parser-1.0.2-py2.py3-none-any.whl.

File metadata

  • Download URL: cql_parser-1.0.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 43.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for cql_parser-1.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 23710186e7f5a4485dcb66ba69aab6f54fa71ff63230218a4d51ae53af75b3c7
MD5 cf1ad685e44da1d0a4603ed7de4cede3
BLAKE2b-256 3a46373047b976d06ce5e0cb9de1466ab4358e67769729994caa4cab4ef79094

See more details on using hashes here.

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