Skip to main content

A Parser for a D-Bus Signature

A parser for a dbus signature.

Introduction

This module contains a parser for dbus signatures constructed using the pyparsing library (http://pyparsing.wikispaces.com/).

The grammar follows the informal specifications at https://dbus.freedesktop.org/doc/dbus-specification.html. This grammar is a very simple one, parsable by an LL(1) parser.

The grammar has undergone significant testing using the Hypothesis testing library (http://hypothesis.works/).

Usage and Implementation Hints

Usage of the library to verify that a string is a signature is fairly straightforward:

>>> from dbus_signature_pyparsing import Parser
>>> parser = Parser()
>>> parser.PARSER.parseString("a(qy)", parseAll=True)

If parseString() does not raise a pyparsing exception, the argument string is a valid signature.

Note that the empty string is a valid signature. Thus, it is important to require that the parser parse the entire string by setting the parseAll parameter to True. If parseAll is False, which is the default, the parser can always parse the empty string, and every string will be parsed and verified to be a valid signature.

The Parser object exposes all its sub-parsers as instance attributes. The PARSER attribute is the top-level parser, suitable for parsing general signatures. The COMPLETE attribute parses what is defined in the informal specification as a “single complete type”. The CODE attribute is equivalent to the specification’s “type code”.

The parser is easily used either by delegation or by inheritance. Each sub-parser attribute is a ParserElement; consequently each sub-parser supports the addParseAction() method. To customize the basic parser to return a particular value as a result of having parsed a signature invoke the addParseAction() method on each appropriate sub-parser with an appropriately chosen method. The modified parser should then return the desired value when the parseString() method is invoked on a valid signature string. For further assistance, consult pyparsing’s extensive documentation at http://pyparsing.wikispaces.com/ and https://pythonhosted.org/pyparsing/.

Packaging

Downstream packagers, if incorporating testing into their packaging, are encouraged to use only the tests in the test_deterministic.py module, to avoid testing failures that may arise due to the non-deterministic behavior of Hypothesis tests.

Release files for dbus-signature-pyparsing 0.4.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 dbus-signature-pyparsing 0.4.2
File Size Uploaded
dbus_signature_pyparsing-0.4.2.tar.gz 8.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dbus-signature-pyparsing 0.4.2
File Interpreter ABI Platform
dbus_signature_pyparsing-0.4.2-py3-none-any.whl Python 3 none any Details

Total release size: 17.3 kB

Release files / dbus_signature_pyparsing-0.4.2.tar.gz

Download URL dbus_signature_pyparsing-0.4.2.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2b253cd7d3c7ff19c724f2f77f1765ada2e727b0a9ecc3593c0cce4247596052
BLAKE2b-256 checksum
How to use checksums
ac4883216afa6c64a69105ccc948e70124952b62f2d8272a49a98dda4c05ff1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.7

Release files / dbus_signature_pyparsing-0.4.2-py3-none-any.whl

Download URL dbus_signature_pyparsing-0.4.2-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4244f19d773e609852793a54e98a7f35eba444bc53e9478ff46f48d513b4b855
BLAKE2b-256 checksum
How to use checksums
6202235e19ea3b80e074b6eac3476c654e07ea7b3a73b6cfdb3c55afc64364eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.7

Release history Release notifications | RSS feed

0.4.3

2 release files

This release

0.4.2 This release

2 release files

0.4.1

2 release files

0.4

2 release files

0.3

1 release file

0.2

1 release file

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