cql-parser


Namecql-parser JSON
Version 1.0.2 PyPI version JSON
download
home_pagehttps://github.com/Querela/cql-python/
Summary"CQL (Contextual Query Language) Parser"
upload_time2023-11-01 13:59:39
maintainer
docs_urlNone
authorErik Körner
requires_python>=3.8
licenseMIT
keywords cql clarin query parser
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # CQL (Contextual Query Language) Parser (for Python)

<!-- START: BADGES -->
[![cql-parser @ PyPI](https://img.shields.io/pypi/v/cql-parser)](https://pypi.python.org/pypi/cql-parser)
[![](https://img.shields.io/github/last-commit/Querela/cql-python)](https://github.com/Querela/cql-python/commits/main)
[![Github Actions: Python package](https://github.com/Querela/cql-python/actions/workflows/python-package.yml/badge.svg)](https://github.com/Querela/cql-python/actions/workflows/python-package.yml)

[![](https://img.shields.io/badge/%20code%20style-black-000000)](https://github.com/psf/black)
[![](https://img.shields.io/badge/%20imports-isort-%231674b1)](https://pycqa.github.io/isort/)
[![](https://img.shields.io/badge/linting-flake8-yellowgreen)](https://github.com/PyCQA/flake8)  
[![](https://img.shields.io/badge/%20doc%20style-sphinx-0a507a.svg)](https://www.sphinx-doc.org/en/master/usage/index.html)
[![](https://img.shields.io/badge/%20doc%20style-google-3666d6.svg)](https://google.github.io/styleguide/pyguide.html#s3.8-comments-and-docstrings)
<!-- END: BADGES -->

* [Grammar and Specification](http://www.loc.gov/standards/sru/cql/spec.html)

## 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

* Python 3.8+ (only tested on 3.8.10)
* [`ply` _(github version)_](https://github.com/dabeaz/ply) - vendored in [`src/cql/_vendor/ply`](src/cql/_vendor/ply)
* [`pytest`](https://docs.pytest.org/) for testing

## Building

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

## Install

```bash
# 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:
```python
import cql

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

A bit more involved:
```python
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`](src/cql/__init__.py) or the various test files in [`tests/`](tests/).

## Development

* Uses `pytest` (with coverage, clarity and randomly plugins).
* See test files in [`tests/`](tests/) folder. The **regression** test files are a copy from [`indexdata/cql-java`](https://github.com/indexdata/cql-java) and are not included in the built package. _The **XCQL** serialization differs slightly from the only [CQL Python 'library'](https://github.com/cheshire3/cheshire3/blob/develop/cheshire3/cqlParser.py) I could find._
* As for changing the lexer or parser, see [`ply` docs](http://www.dabeaz.com/ply/ply.html).

Run all tests with:
```bash
# install test dependencies
python3 -m install -e .[test]
# run
pytest
```

Run style checks:
```bash
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:
```bash
python3 -m pip install -e .[vendor]
vendoring sync
# NOTE: some changes still not automated ...
git checkout -- src/cql/_vendor/ply/LICENSE
```

## See also

* http://zing.z3950.org/cql
* http://www.loc.gov/standards/sru/cql/index.html
* Other implementations: [Java](https://github.com/indexdata/cql-java), [JavaScript](https://github.com/Querela/cql-js), etc.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Querela/cql-python/",
    "name": "cql-parser",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "CQL,CLARIN,Query Parser",
    "author": "Erik K\u00f6rner",
    "author_email": "\"Erik K\u00f6rner\" <koerner@saw-leipzig.de>",
    "download_url": "https://files.pythonhosted.org/packages/90/6a/41d59a65d3411017ee1ad222066b612a1cf755fb03dda8ca7771ea3e6e80/cql-parser-1.0.2.tar.gz",
    "platform": null,
    "description": "# CQL (Contextual Query Language) Parser (for Python)\n\n<!-- START: BADGES -->\n[![cql-parser @ PyPI](https://img.shields.io/pypi/v/cql-parser)](https://pypi.python.org/pypi/cql-parser)\n[![](https://img.shields.io/github/last-commit/Querela/cql-python)](https://github.com/Querela/cql-python/commits/main)\n[![Github Actions: Python package](https://github.com/Querela/cql-python/actions/workflows/python-package.yml/badge.svg)](https://github.com/Querela/cql-python/actions/workflows/python-package.yml)\n\n[![](https://img.shields.io/badge/%20code%20style-black-000000)](https://github.com/psf/black)\n[![](https://img.shields.io/badge/%20imports-isort-%231674b1)](https://pycqa.github.io/isort/)\n[![](https://img.shields.io/badge/linting-flake8-yellowgreen)](https://github.com/PyCQA/flake8)  \n[![](https://img.shields.io/badge/%20doc%20style-sphinx-0a507a.svg)](https://www.sphinx-doc.org/en/master/usage/index.html)\n[![](https://img.shields.io/badge/%20doc%20style-google-3666d6.svg)](https://google.github.io/styleguide/pyguide.html#s3.8-comments-and-docstrings)\n<!-- END: BADGES -->\n\n* [Grammar and Specification](http://www.loc.gov/standards/sru/cql/spec.html)\n\n## Notice\n\nPrefix parsing and resolution is still work-in-progress!\nTest cases mostly check out but it definitely needs to be finished before\nusing in real world scenarios.\n\n## Requires\n\n* Python 3.8+ (only tested on 3.8.10)\n* [`ply` _(github version)_](https://github.com/dabeaz/ply) - vendored in [`src/cql/_vendor/ply`](src/cql/_vendor/ply)\n* [`pytest`](https://docs.pytest.org/) for testing\n\n## Building\n\n```bash\n# see: https://setuptools.pypa.io/en/latest/build_meta.html\npython3 -m pip install -q build\npython3 -m build\n```\n\n## Install\n\n```bash\n# built package\npython3 -m pip install dist/cql_parser-<version>-py2.py3-none-any.whl\n# or\npython3 -m pip install dist/cql-parser-<version>.tar.gz\n\n# for local development\npython3 -m pip install -e .[test]\n```\n\n## Usage\n\nReally quick:\n```python\nimport cql\n\nprint(cql.parse(\"dc.title any fish\").toXCQLString(pretty=True))\n```\n\nA bit more involved:\n```python\nimport logging\nlogging.basicConfig(level=logging.DEBUG)\n\nfrom cql.parser import CQLParser12\n\n# use CQL version 1.2 parser\ncqlparser = CQLParser12()\nquery = cqlparser.run(\"dc.title any fish\")\n# do something with the output\nprint(query.toCQL())\nprint(query.toXCQLString(pretty=True))\n```\n\nA for a deeper dive, take a look at [`src/cql/__init__.py`](src/cql/__init__.py) or the various test files in [`tests/`](tests/).\n\n## Development\n\n* Uses `pytest` (with coverage, clarity and randomly plugins).\n* See test files in [`tests/`](tests/) folder. The **regression** test files are a copy from [`indexdata/cql-java`](https://github.com/indexdata/cql-java) and are not included in the built package. _The **XCQL** serialization differs slightly from the only [CQL Python 'library'](https://github.com/cheshire3/cheshire3/blob/develop/cheshire3/cqlParser.py) I could find._\n* As for changing the lexer or parser, see [`ply` docs](http://www.dabeaz.com/ply/ply.html).\n\nRun all tests with:\n```bash\n# install test dependencies\npython3 -m install -e .[test]\n# run\npytest\n```\n\nRun style checks:\n```bash\npython3 -m pip install -e .[style]\nblack --check .\nflake8 . --show-source --statistics\nisort --check --diff .\n\n# building the package:\npython3 -m pip install -e .[build]\npython3 -m build\ntwine check --strict dist/*\n```\n\nVendor dependencies:\n```bash\npython3 -m pip install -e .[vendor]\nvendoring sync\n# NOTE: some changes still not automated ...\ngit checkout -- src/cql/_vendor/ply/LICENSE\n```\n\n## See also\n\n* http://zing.z3950.org/cql\n* http://www.loc.gov/standards/sru/cql/index.html\n* Other implementations: [Java](https://github.com/indexdata/cql-java), [JavaScript](https://github.com/Querela/cql-js), etc.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "\"CQL (Contextual Query Language) Parser\"",
    "version": "1.0.2",
    "project_urls": {
        "Homepage": "https://github.com/Querela/cql-python/",
        "Issue Tracker": "https://github.com/Querela/cql-python/issues",
        "Source": "https://github.com/Querela/cql-python/"
    },
    "split_keywords": [
        "cql",
        "clarin",
        "query parser"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "906a41d59a65d3411017ee1ad222066b612a1cf755fb03dda8ca7771ea3e6e80",
                "md5": "c8552aea7d03eb413f2eb3c81e14fce5",
                "sha256": "c5b827add9f3753baac88450e88cce9fe99e999b7f01dcfb33edf81050a61f37"
            },
            "downloads": -1,
            "filename": "cql-parser-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "c8552aea7d03eb413f2eb3c81e14fce5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 48676,
            "upload_time": "2023-11-01T13:59:39",
            "upload_time_iso_8601": "2023-11-01T13:59:39.675487Z",
            "url": "https://files.pythonhosted.org/packages/90/6a/41d59a65d3411017ee1ad222066b612a1cf755fb03dda8ca7771ea3e6e80/cql-parser-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-01 13:59:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Querela",
    "github_project": "cql-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cql-parser"
}
        
Elapsed time: 0.13765s