Skip to main content

A parser for Logical Query Protocol (LQP) S-expressions into Protobuf

Project description

python-tools

A command-line tool to parse Logical Query Protocol (LQP) S-expressions into Protobuf binary and JSON formats.

Usage

usage: lqp [-h] [--bin BIN] [--json JSON] input_directory

Parse LQP S-expression into Protobuf binary and JSON files.

positional arguments:
  input_directory  path to the input LQP S-expression files

options:
  -h, --help       show this help message and exit
  --bin BIN        output directory for the binary encoded protobuf
  --json JSON      output directory for the JSON encoded protobuf

Build

Install preprequisites:

pip install pip build setuptools wheel

Then build the module itself:

python -m build

Install locally:

pip install [--user] [--force-reinstall] dist/lqp-0.1.0-py3-none-any.whl

Running tests

Within python-tools,

Setup:

python -m pip install -e ".[test]"
python -m pip install pyrefly

Running tests:

python -m pytest

Type checking:

pyrefly check

Formatting

The LQP S-expression syntax was chosen to align with that of the Clojure programming language, in order to leverage the existing tools in that ecosystem. LQP syntax should be formatted via cljfmt with the following configuration:

;; .cljfmt.edn
{:indents {#re ".*" [[:inner 0]]}
 :remove-surrounding-whitespace?  false
 :remove-trailing-whitespace?     false
 :remove-consecutive-blank-lines? false}

This configuration is explained here and simply works better for LQP, which does not have many of the Clojure keywords that are treated as special cases during formatting by default.

See the next section for an easy way to integrate cljfmt into your VSCode workflow.

VSCode

Editing nested S-expressions by hand can get a little tedious, which is why paredit is an established tool in the Clojure world. To integrate paredit and cljfmt into your VSCode workflow, just install the Calva extension and follow the configuration guide to use the cljfmt configuration pasted in the previous section.

Out-of-the-box, Calva also runs a Clojure linter, which of course does not know what to do with LQP, resulting in lots of squiggly lines. For that reason, it is also advisable to create the following config file at .lsp/config.edn from the project root:

;; .lsp/config.edn
{:linters {:clj-kondo {:level :off}}}

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

lqp-0.1.7.tar.gz (30.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lqp-0.1.7-py3-none-any.whl (31.2 kB view details)

Uploaded Python 3

File details

Details for the file lqp-0.1.7.tar.gz.

File metadata

  • Download URL: lqp-0.1.7.tar.gz
  • Upload date:
  • Size: 30.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for lqp-0.1.7.tar.gz
Algorithm Hash digest
SHA256 c430220d4832e756e8cf4cd570bba9cff15f891e45b8a9b390e81c67e0e651d3
MD5 93a9dd5aac724b6c1c9b449b407b76b7
BLAKE2b-256 1d865ce0d6b65d047bf2a828e21f6bf2999fbac28c6fadb56925d3a9f80e737c

See more details on using hashes here.

File details

Details for the file lqp-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: lqp-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 31.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for lqp-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 57fc0104e3f23f9f6e0d94fe158105da52edd99e9e39465243f22cf6597b4d5b
MD5 5c065f76c09e5495785c6fed7c9f638f
BLAKE2b-256 b3270017949294fd842eac05181e3906026f9beedfb77c4b6a59ae5a9e4b4081

See more details on using hashes here.

Supported by

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