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.
Raw data
{
"_id": null,
"home_page": "https://github.com/stratis-storage/dbus-signature-pyparsing",
"name": "dbus-signature-pyparsing",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Anne Mulhern",
"author_email": "amulhern@redhat.com",
"download_url": "https://files.pythonhosted.org/packages/c3/36/0b3b99b6c5fb7c6e1ea2f1ee40d49db199805ab3e9431ae6710f9e01470d/dbus-signature-pyparsing-0.4.1.tar.gz",
"platform": "Linux",
"description": "A Parser for a D-Bus Signature\n==============================\n\nA parser for a dbus signature.\n\nIntroduction\n------------\n\nThis module contains a parser for dbus signatures constructed using the\npyparsing library (http://pyparsing.wikispaces.com/).\n\nThe grammar follows the informal specifications at\nhttps://dbus.freedesktop.org/doc/dbus-specification.html.\nThis grammar is a very simple one, parsable by an LL(1) parser.\n\nThe grammar has undergone significant testing using the Hypothesis testing\nlibrary (http://hypothesis.works/).\n\nUsage and Implementation Hints\n------------------------------\n\nUsage of the library to verify that a string is a signature is fairly\nstraightforward::\n\n >>> from dbus_signature_pyparsing import Parser\n >>> parser = Parser()\n >>> parser.PARSER.parseString(\"a(qy)\", parseAll=True)\n\nIf parseString() does not raise a pyparsing exception, the argument string\nis a valid signature.\n\nNote that the empty string is a valid signature. Thus, it is important to\nrequire that the parser parse the entire string by setting the parseAll\nparameter to True. If parseAll is False, which is the default, the parser\ncan always parse the empty string, and every string will be parsed and verified\nto be a valid signature.\n\nThe Parser object exposes all its sub-parsers as instance attributes.\nThe PARSER attribute is the top-level parser, suitable for parsing general\nsignatures. The COMPLETE attribute parses what is defined in the\ninformal specification as a \"single complete type\". The CODE attribute is\nequivalent to the specification's \"type code\".\n\nThe parser is easily used either by delegation or by inheritance. Each\nsub-parser attribute is a ParserElement; consequently each sub-parser supports\nthe addParseAction() method. To customize the basic parser to return a\nparticular value as a result of having parsed a signature invoke the\naddParseAction() method on each appropriate sub-parser with an appropriately\nchosen method. The modified parser should then return the desired value when\nthe parseString() method is invoked on a valid signature string.\nFor further assistance, consult pyparsing's extensive documentation at\nhttp://pyparsing.wikispaces.com/ and https://pythonhosted.org/pyparsing/.\n\nPackaging\n---------\n\nDownstream packagers, if incorporating testing into their packaging, are\nencouraged to use only the tests in the test_deterministic.py module, to\navoid testing failures that may arise due to the non-deterministic behavior\nof Hypothesis tests.\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "\"dbus signature parser\"",
"version": "0.4.1",
"project_urls": {
"Homepage": "https://github.com/stratis-storage/dbus-signature-pyparsing"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "055eb06d6dc70c537a2d38b64b2e742c939e2fd0d4239b5ad10ed63fad2ad8b5",
"md5": "d903ca09817107d65cef397a85e1fde4",
"sha256": "d2c7464ad55d918aa5c802988eb3e3bae9710aad127dca4dd53c3832108d2922"
},
"downloads": -1,
"filename": "dbus_signature_pyparsing-0.4.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d903ca09817107d65cef397a85e1fde4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 9187,
"upload_time": "2023-05-08T02:26:30",
"upload_time_iso_8601": "2023-05-08T02:26:30.830642Z",
"url": "https://files.pythonhosted.org/packages/05/5e/b06d6dc70c537a2d38b64b2e742c939e2fd0d4239b5ad10ed63fad2ad8b5/dbus_signature_pyparsing-0.4.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c3360b3b99b6c5fb7c6e1ea2f1ee40d49db199805ab3e9431ae6710f9e01470d",
"md5": "e1c57026373d2de9b57c871697f5ab55",
"sha256": "52d52d4577d5704dc6c32ff83ae5e9618a6d2aa2446144c35cbeccc2a654de7c"
},
"downloads": -1,
"filename": "dbus-signature-pyparsing-0.4.1.tar.gz",
"has_sig": false,
"md5_digest": "e1c57026373d2de9b57c871697f5ab55",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 8079,
"upload_time": "2023-05-08T02:26:32",
"upload_time_iso_8601": "2023-05-08T02:26:32.354546Z",
"url": "https://files.pythonhosted.org/packages/c3/36/0b3b99b6c5fb7c6e1ea2f1ee40d49db199805ab3e9431ae6710f9e01470d/dbus-signature-pyparsing-0.4.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-08 02:26:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "stratis-storage",
"github_project": "dbus-signature-pyparsing",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "dbus-signature-pyparsing"
}