{ "info": { "author": "Anne Mulhern", "author_email": "amulhern@redhat.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: POSIX :: Linux", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "A transformer to dbus-python types\n==================================\n\nFacilities for converting an object that inhabits core Python types, e.g.,\nlists, ints, dicts, to an object that inhabits dbus-python types, e.g.,\ndbus.Array, dbus.UInt32, dbus.Dictionary based on a specified dbus signature.\n\nMotivation\n----------\n\nThe dbus-python library is a library of python bindings for libdbus. It does\nnot provide facilities to ensure that the types of the values that client code\nplaces on the D-Bus conform to the required signature. The client code may\neither be a D-Bus service, so that the values that it places on the D-Bus\nshould conform to the signature that it specifies, or, in some cases, a client\nof the service, which must conform to the specifications of the service.\n\nIf a service implements the Introspectable interface on its objects,\ndbus-python will use the signature information to massage client messages\ninto the correct dbus types. If the Introspectable interface is unavailable,\ndbus-python will guess the signature by recursively examining the values of\nthe arguments, and will then proceed the same as before. If the signature\ncontains a 'v', indicating a variant type, dbus-python must guess the type\nof the correspdoning value. dbus-python can be instructed not to make use of\ndbus introspection by setting the introspect parameter to false in the\nappropriate methods.\n\nThis library provides facilities to ensure that values placed on the D-Bus\nconform to a given signature, by wrapping the values in the appropriate\nconstructors for this signature. It generates correct functions for any\nvalid signature.\n\nUsage and Implementation Hints\n------------------------------\n\nUsage of the library is fairly straightforward::\n\n >>> from into_dbus_python import xformers\n >>> funcs = xformers(\"adq\")\n >>> len(funcs)\n 2\n\nNote that the length of the list of functions is the same as the number of\ncomplete types in the signature. Each element in the list of functions is\na tuple. ::\n\n >>> funcs[0]\n (.the_func at 0x7f4542f2d730>, 'ad')\n\nThe first element is the function itself, the second is a string which\nmatches the complete type signature for which this function yields values of\nthe correct type. Applying this function yields the actual value ::\n\n >>> funcs[0][0]([2.3, 37.5])\n (dbus.Array([dbus.Double(2.3), dbus.Double(37.5)], signature=dbus.Signature('d')), 0)\n\nIn this example, the signature was \"ad\" so the resulting value is a dbus.Array\nof dbus.Double objects. The signature parameter has the appropriate value;\nit is just 'd', the symbol for the type of the elements in the array,\ndouble. Note that the function also yields a tuple, the converted value and\nan int, which represents the variant level. Since there was no \"v\" in the\nsignature, the variant level is 0.\n\nThe generated functions will fail with an IntoDPError if passed invalid\narguments. ::\n\n >>> try:\n ... funcs[0][0](True)\n ... except IntoDPError as err:\n ... print(\"bad arg\")\n ...\n bad arg\n\nIf any of the functions raises an exception that is not a subtype of\nIntoDPError this constitutes a bug and is not part of the public API.\n\nConveniences\n------------\nThe parser itself returns a list of tuples, of which generally only the first\nelement in the tuple is of interest to the client. The second element, the\nstring matched, is a necessary result for the recursive implementation,\nbut is not generally useful to the client. The resulting functions each\nreturn a tuple of the transformed value and the variant level, generally only\nthe transformed value is of interest to the client.\n\nFor this reason, the library provides a convenience function, xformer(),\nwhich takes a signature and returns a function, which takes a list of objects\nand returns the list, transformed to appropriate dbus types. It can be used\nin the following way::\n\n >>> from into_dbus_python import xformer\n >>> func = xformer(\"adq\")\n >>> func([[2.3, 34.0], 3])\n [dbus.Array([dbus.Double(2.3), dbus.Double(34.0)], signature=dbus.Signature('d')), dbus.UInt16(3)]\n\nNote that the function must take a list of values, one for each complete type\nin the signature. Here, there are two complete types \"ad\", and \"q\", and there\nare two resulting values.\n\nIf the signature contains a \"v\", for a variant type, the value must be a pair\nof a signature and a value that inhabits that type. For example, ::\n\n >>> func = xformer(\"v\")\n >>> func([(\"aq\", [0, 1])])\n [dbus.Array([dbus.UInt16(0), dbus.UInt16(1)], signature=dbus.Signature('q'), variant_level=1)]\n\nNote that the variant level of the constructed Array object is 1. A non-zero\nvariant level in the dbus object indicates that the object is a variant.\nIn this example the variant level is just 1. Further nesting of variants is\npermitted, the variant level increases by one with each level. ::\n\n >>> func([(\"av\", [(\"q\", 0)])])\n [dbus.Array([dbus.UInt16(0, variant_level=1)], signature=dbus.Signature('v'), variant_level=2)]\n\nHere the variant level of the variant element in the array, 0, is 1, but the\nvariant level of the whole array is 2, since the array inhabits a variant type\nand contains a variant element.\n\nRestrictions on Core Types\n--------------------------\nThe generated functions place as few restrictions as possible on the types\nof the values to be transformed. Generally speaking, a tuple is as good as a\nlist, since both are iterable. ::\n\n >>> func = xformer(\"adq\")\n >>> func([(2.3, 34.0), 3])\n [dbus.Array([dbus.Double(2.3), dbus.Double(34.0)], signature=dbus.Signature('d')), dbus.UInt16(3)]\n\nHowever, the inhabitant of a dbus.Dictionary type must be an object with an\nitems() method which yields pairs of keys and values, e.g., a dict.\n\nThe signature() function\n------------------------\nThis library also exposes a function, signature(), which, given a value in\ndbus-python types, calculates its signature. It has the following relation\nto the xformer() function.\n\nLet S be a signature. Let C be a list of values in Python core types.\nLet V = xformer(S)(C). Then \"\".join(signature(v) for v in V) is equal to S.\n\nTechnical Remarks\n-----------------\n\nThis package extends the parser for dbus signatures implemented in the\ndbus-signature-pyparsing package\n(https://github.com/stratis-storage/dbus-signature-pyparsing)\nby adding actions to the individual parsers using the setParseAction() method.\n\nThe package has undergone significant testing using the Hypothesis testing\nlibrary (http://hypothesis.works/) and the external Hypothesis strategy\nimplemented in the hs-dbus-signature package\n(https://github.com/stratis-storage/hs-dbus-signature).", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/stratis-storage/into-dbus-python", "keywords": "", "license": "Apache 2.0", "maintainer": "", "maintainer_email": "", "name": "into-dbus-python", "package_url": "https://pypi.org/project/into-dbus-python/", "platform": "Linux", "project_url": "https://pypi.org/project/into-dbus-python/", "project_urls": { "Homepage": "https://github.com/stratis-storage/into-dbus-python" }, "release_url": "https://pypi.org/project/into-dbus-python/0.7/", "requires_dist": null, "requires_python": "", "summary": "transforms values into properly wrapped dbus-python objects", "version": "0.7" }, "last_serial": 5388987, "releases": { "0.2": [ { "comment_text": "", "digests": { "md5": "f091e8f003e255a57a0dc546001a282b", "sha256": "a1ad90801eaa0c3108700231417d9e3d8e043b9888eb49a3d6415412f10b30b8" }, "downloads": -1, "filename": "into-dbus-python-0.2.tar.gz", "has_sig": false, "md5_digest": "f091e8f003e255a57a0dc546001a282b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15842, "upload_time": "2016-10-21T15:16:53", "url": "https://files.pythonhosted.org/packages/32/48/8e4b1d84dc1e822e8cdd8970be77f998529466e093d55708d9a1161a88a9/into-dbus-python-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "95bbd49be250bbd9641109125b7667bf", "sha256": "b62a84832be6323d6b306c7b321f1bda6e61fd5444c454025ac8aa743ddf5bbb" }, "downloads": -1, "filename": "into-dbus-python-0.3.tar.gz", "has_sig": false, "md5_digest": "95bbd49be250bbd9641109125b7667bf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16740, "upload_time": "2016-11-16T19:41:30", "url": "https://files.pythonhosted.org/packages/20/e9/bfbd459019a84c590d6eb2d48e896e65686670eb62b81dfab4deaa2279ce/into-dbus-python-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "b80103c2150272d542890b5e6d6caee2", "sha256": "6e5c4b9dd91d64e39d8c5d20bb3c7f128323e539578efc13a359e06f080a83f6" }, "downloads": -1, "filename": "into-dbus-python-0.4.tar.gz", "has_sig": false, "md5_digest": "b80103c2150272d542890b5e6d6caee2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16971, "upload_time": "2016-11-24T19:09:50", "url": "https://files.pythonhosted.org/packages/ca/b4/f321280d55f6f17a8a1a9225fc23556e259377c0b74c712c46cfcef6ba48/into-dbus-python-0.4.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "8b1b961957e33cb239a642d93ed41d40", "sha256": "f705f89084978fa52ad7574da91e632fb4b5daa30fe0000b2e3986a19e4314ff" }, "downloads": -1, "filename": "into-dbus-python-0.5.tar.gz", "has_sig": false, "md5_digest": "8b1b961957e33cb239a642d93ed41d40", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17702, "upload_time": "2016-11-25T14:21:02", "url": "https://files.pythonhosted.org/packages/b9/c8/bee42374559449bf8b853aaf9fc32a1ff53edc21012f296ebe0677fa90ee/into-dbus-python-0.5.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "9d547091878a831ccb4fca51f5cbbd28", "sha256": "d605b70062784b7e74022fe58e6d1e1c55a974a1dbcd39a70d97e95735120a4e" }, "downloads": -1, "filename": "into-dbus-python-0.6.tar.gz", "has_sig": false, "md5_digest": "9d547091878a831ccb4fca51f5cbbd28", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18017, "upload_time": "2017-01-27T14:08:48", "url": "https://files.pythonhosted.org/packages/62/20/f00e77ce10c077af2e933077b06d914644064933dec4614a3f2f2dccc677/into-dbus-python-0.6.tar.gz" } ], "0.7": [ { "comment_text": "", "digests": { "md5": "8a8523820d3c4f51d0c922f2d4b27506", "sha256": "f35fc93e1065ed205fdd6f6c8def1c040b528fd00a9ef263552a0bdac63320b5" }, "downloads": -1, "filename": "into-dbus-python-0.7.tar.gz", "has_sig": false, "md5_digest": "8a8523820d3c4f51d0c922f2d4b27506", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17727, "upload_time": "2019-06-12T01:38:17", "url": "https://files.pythonhosted.org/packages/9a/09/d054fd4e9f3a7f63ceb1247a2d5043c6df03a3c33db8b5492face5a25cc3/into-dbus-python-0.7.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8a8523820d3c4f51d0c922f2d4b27506", "sha256": "f35fc93e1065ed205fdd6f6c8def1c040b528fd00a9ef263552a0bdac63320b5" }, "downloads": -1, "filename": "into-dbus-python-0.7.tar.gz", "has_sig": false, "md5_digest": "8a8523820d3c4f51d0c922f2d4b27506", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17727, "upload_time": "2019-06-12T01:38:17", "url": "https://files.pythonhosted.org/packages/9a/09/d054fd4e9f3a7f63ceb1247a2d5043c6df03a3c33db8b5492face5a25cc3/into-dbus-python-0.7.tar.gz" } ] }