{ "info": { "author": "Kevin Valk", "author_email": "valk@riscure.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Topic :: Utilities" ], "description": "# Inspector Trace Set `.trs` file support in Python\n[![Build Status](https://travis-ci.com/Riscure/python-trsfile.svg?branch=master)](https://travis-ci.com/Riscure/python-trsfile)\n[![Documentation Status](https://readthedocs.org/projects/trsfile/badge/)](https://trsfile.readthedocs.io/)\n\nRiscure Inspector uses the `.trs` file format to save and read traces from disk. To better assist reading and writing trace set files from third parties, Riscure published this Python library.\n\n## Quick start\nThis library supports reading and writing of `.trs` files, but it does not (*yet*) support modifying existing `.trs` files. Both the `TraceSet` and the `Trace` class emulate all the functionality of a `list`, so slice to your heart's content!\n\n### Installation\nThis library is available on [PyPi](https://www.pypi.org/project/trsfile/) for Python 3 and up. Just add `trsfile` to your `requirements.txt` or install it via the command line:\n```shell\npip install trsfile\n```\n\n### Reading `.trs` files\n```python\nimport trsfile\n\nwith trsfile.open('trace-set.trs', 'r') as traces:\n\t# Show all headers\n\tfor header, value in trs_file.get_headers().items():\n\t\tprint(header, '=', value)\n\tprint()\n\n\t# Iterate over the first 25 traces\n\tfor i, trace in enumerate(trs_file[0:25]):\n\t\tprint('Trace {0:d} contains {1:d} samples'.format(i, len(trace)))\n\t\tprint(' - minimum value in trace: {0:f}'.format(min(trace)))\n\t\tprint(' - maximum value in trace: {0:f}'.format(max(trace)))\n```\n\n### Creating `.trs` files\n```python\nimport random, os, trsfile\nfrom trsfile import trs_open, Trace, SampleCoding, TracePadding, Header\n\nwith trs_open(\n\t\t'trace-set.trs', # File name of the trace set\n\t\t'w', # Mode: r, w, x, a (default to x)\n\t\t# Zero or more options can be passed (supported options depend on the storage engine)\n\t\tengine = 'TrsEngine', # Optional: how the trace set is stored (defaults to TrsEngine)\n\t\theaders = { # Optional: headers (see Header class)\n\t\t\tHeader.LABEL_X: 'Testing X',\n\t\t\tHeader.LABEL_Y: 'Testing Y',\n\t\t\tHeader.DESCRIPTION: 'Testing trace creation',\n\t\t},\n\t\tpadding_mode = TracePadding.AUTO,# Optional: padding mode (defaults to TracePadding.AUTO)\n\t\tlive_update = True # Optional: updates the TRS file for live preview (small performance hit)\n\t\t # 0 (False): Disabled (default)\n\t\t # 1 (True) : TRS file updated after every trace\n\t\t # N : TRS file is updated after N traces\n\t) as trs_file:\n\t# Extend the trace file with 100 traces with each 1000 samples\n\ttrs_file.extend([\n\t\tTrace(\n\t\t\tSampleCoding.FLOAT,\n\t\t\t[random.uniform(-255, 255) for _ in range(0, 1000)],\n\t\t\tdata = os.urandom(16)\n\t\t)\n\t\tfor _ in range(0, 100)]\n\t)\n\n\t# Replace 5 traces (the slice [0:10:2]) with random length traces.\n\t# Because we are creating using the TracePadding.PAD mode, all traces\n\t# will be clipped or padded on the first trace length\n\ttrs_file[0:10:2] = [\n\t\tTrace(\n\t\t\tSampleCoding.FLOAT,\n\t\t\t[random.uniform(0, 255) for _ in range(0, random.randrange(1000))],\n\t\t\tdata = os.urandom(16),\n\t\t\ttitle = 'Clipped trace'\n\t\t)\n\t\tfor _ in range(0, 5)\n\t]\n\n\t# Adding one Trace\n\ttrs_file.append(\n\t\tTrace(\n\t\t\tSampleCoding.FLOAT,\n\t\t\t[random.uniform(-255, 255) for _ in range(0, 1000)],\n\t\t\tdata = os.urandom(16)\n\t\t)\n\t)\n\n\t# We cannot delete traces with the TrsEngine, other engines do support this feature\n\t#del trs_file[40:50]\n\n\t# We can only change headers with a value that has the same length as the previous value\n\t# with the TrsEngine, other engines can support dynamically adding, deleting or changing\n\t# headers.\n\t#trs_file.update_header(Header.LABEL_X, 'Time')\n\t#trs_file.update_header(Header.LABEL_Y, 'Voltage')\n\t#trs_file.update_header(Header.DESCRIPTION, 'Traces created for some purpose!')\n\n\tprint('Total length of new trace set: {0:d}'.format(len(trs_file)))\n```\n\n### Converting `TraceSet` from one type to another\n```python\nimport random, os, trsfile\n\nwith \\\n\ttrsfile.open(\n\t\t'trace-set', # Previously create trace set\n\t\t'r', # Read only mode\n\t\tengine='FileEngine' # Using the FileEngine\n\t) as traces, \\\n\ttrsfile.open( # Note: TrsEngine is the default\n\t\t'trace-set.trs', # Name of the new trace set\n\t\t'w', # Write mode\n\t\theaders=traces.get_headers() # Copy the headers\n\t) as new_traces:\n\tnew_traces.extend(traces) # Extend the new trace set with the\n\t # traces from the old trace set\n```\n\n## Documentation\nThe full documentation is available in the `docs` folder with a readable version on [Read the Docs](https://trsfile.readthedocs.io/).\n\n## Testing\nThe library supports Python `unittest` module and the tests can be executed with the following command:\n```\npython -m unittest\n```\n\n## License\n[BSD 3-Clause Clear License](https://choosealicense.com/licenses/bsd-3-clause-clear/)\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/riscure/python-trsfile", "keywords": "trs trace inspector riscure", "license": "BSD 3-Clause Clear License", "maintainer": "", "maintainer_email": "", "name": "trsfile", "package_url": "https://pypi.org/project/trsfile/", "platform": "", "project_url": "https://pypi.org/project/trsfile/", "project_urls": { "Bug Reports": "https://github.com/riscure/python-trsfile/issues", "Documentation": "https://trsfile.readthedocs.io/en/latest", "Homepage": "https://github.com/riscure/python-trsfile", "Riscure": "https://www.riscure.com" }, "release_url": "https://pypi.org/project/trsfile/0.3.1/", "requires_dist": [ "numpy" ], "requires_python": "", "summary": "Library to read and create Riscure Inspector trace set files (.trs)", "version": "0.3.1" }, "last_serial": 5431075, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "99345607c86632958163483896b51f62", "sha256": "3335d464247c77f40181715a3ceb05fb835e3b3e20f7a0b42bc992de6fa78d01" }, "downloads": -1, "filename": "trsfile-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "99345607c86632958163483896b51f62", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13148, "upload_time": "2018-08-02T17:02:57", "url": "https://files.pythonhosted.org/packages/c1/a1/687e0711fc1ddceda024fd179e712a31fa7461ccef00440ec96dc7dbf229/trsfile-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a91e981e950f022dc642d5488bcc9f4c", "sha256": "4fdb416ee7568e6c2b38f800a4a17277bf2ce702e07590107f5c6244dd73d5d9" }, "downloads": -1, "filename": "trsfile-0.1.0.tar.gz", "has_sig": false, "md5_digest": "a91e981e950f022dc642d5488bcc9f4c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10200, "upload_time": "2018-08-02T17:02:58", "url": "https://files.pythonhosted.org/packages/28/51/7ac8844d7edf016e6d32b9410a3a13d5dbff39f0e9a4aa9d3f9e146b7176/trsfile-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "3d0c71b2e709541366d72e8adc7876a3", "sha256": "d4a3307f0032f75d15525632bebf7fbcc1d776d272518f0cf9251b9840a31d2c" }, "downloads": -1, "filename": "trsfile-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "3d0c71b2e709541366d72e8adc7876a3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13151, "upload_time": "2018-08-02T17:51:15", "url": "https://files.pythonhosted.org/packages/35/c2/a08fb9546cf0f554967d9a5d74da8d021c1a46b8e96c1b20766eadc600ac/trsfile-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e9fe425c4987b4c1114d457808d7371c", "sha256": "e9af09276f9e6be58b140decb18de0222750eb04c2c1aff72cd0e38122600169" }, "downloads": -1, "filename": "trsfile-0.1.1.tar.gz", "has_sig": false, "md5_digest": "e9fe425c4987b4c1114d457808d7371c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10200, "upload_time": "2018-08-02T17:51:16", "url": "https://files.pythonhosted.org/packages/69/12/a8b116d6a65865d190c84daeef823b0cadabbf97e85e7480190069169b94/trsfile-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "b0210ff0de4dc5b3d4e156c0d8e5ce61", "sha256": "628125ebac8db1fb0b711e3b481f16dd8a912aba855dca516a55f9fd48beef6a" }, "downloads": -1, "filename": "trsfile-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "b0210ff0de4dc5b3d4e156c0d8e5ce61", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13821, "upload_time": "2018-08-24T12:44:04", "url": "https://files.pythonhosted.org/packages/e8/e9/6fb63a807833ce2c55635fc24204b96ebe8a4cc1a47fffa567805fe651b7/trsfile-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "38ab1fc7d7d1d7eb68247678e1bfb700", "sha256": "51bc42dcfdf5daa2372cfebd63b8ff4fdbc376ce87781c1d9884abc8acd56138" }, "downloads": -1, "filename": "trsfile-0.1.2.tar.gz", "has_sig": false, "md5_digest": "38ab1fc7d7d1d7eb68247678e1bfb700", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10549, "upload_time": "2018-08-24T12:44:05", "url": "https://files.pythonhosted.org/packages/18/d8/5bac1415c9054019a47a1f1e6f6b972f9fba2a864754507b2c72055313ce/trsfile-0.1.2.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "23c5a51b695f3c9ca3a12e806a402699", "sha256": "84c7910b39624b0ce69ff9555950f4010edf8c38ed7dcdb849a0db37bb578676" }, "downloads": -1, "filename": "trsfile-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "23c5a51b695f3c9ca3a12e806a402699", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14563, "upload_time": "2019-01-23T09:20:35", "url": "https://files.pythonhosted.org/packages/32/ac/8329da5f11ca86e14d5261501d434d63751a791e773ed01646f88cd828c2/trsfile-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3b632e2a97ce59b3c96bdca9cbb47c2c", "sha256": "dd597354d86e6b74592f7c78c1f535d4e9020a4e5dd0262a61f84e3342a80bb5" }, "downloads": -1, "filename": "trsfile-0.2.0.tar.gz", "has_sig": false, "md5_digest": "3b632e2a97ce59b3c96bdca9cbb47c2c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11164, "upload_time": "2019-01-23T09:20:36", "url": "https://files.pythonhosted.org/packages/0d/b7/d1a686cbb397545c8a23f1b6f76783875fe758dcc0fb1fb4821527a4c395/trsfile-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "60dfb82e671dd94b648315095894c600", "sha256": "522833a98012dbbb4f978e340e3a1c154fa26f68bfb86e8e4ff209ed8469cde0" }, "downloads": -1, "filename": "trsfile-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "60dfb82e671dd94b648315095894c600", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 23851, "upload_time": "2019-02-08T16:57:42", "url": "https://files.pythonhosted.org/packages/0d/10/6307b0774f9e35aaece9e898b1f6e4b6df11a126040158db91c4571e02de/trsfile-0.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f25ffa5e20485ea47327a432cd65fe8c", "sha256": "c1ea45b152dd2eac2b64c27c7a23d0641934a79681d35c464c901156fdbdd012" }, "downloads": -1, "filename": "trsfile-0.2.1.tar.gz", "has_sig": false, "md5_digest": "f25ffa5e20485ea47327a432cd65fe8c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17913, "upload_time": "2019-02-08T16:57:43", "url": "https://files.pythonhosted.org/packages/13/23/974f64bcabe4921e6eee436d3a377f6b110b47902d8b57bddf4f7edd2d7c/trsfile-0.2.1.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "8ca97deb35443ff8bb098697cf3a23cd", "sha256": "73958eb7ab048a46a72c46a019337d581176fe187c80abc5122431425b44bad5" }, "downloads": -1, "filename": "trsfile-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "8ca97deb35443ff8bb098697cf3a23cd", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 24099, "upload_time": "2019-02-19T12:40:52", "url": "https://files.pythonhosted.org/packages/1c/75/695d8ee3a3d962c39867eaf06ae1b60e6b08f2d134d496772f61698086c0/trsfile-0.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "34992f5058456950cbf96f2ab9795a95", "sha256": "ba70065efec4c762b4bd81dc4494106790263d766e1c0484b67cf7bdc412dde7" }, "downloads": -1, "filename": "trsfile-0.3.0.tar.gz", "has_sig": false, "md5_digest": "34992f5058456950cbf96f2ab9795a95", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18120, "upload_time": "2019-02-19T12:40:53", "url": "https://files.pythonhosted.org/packages/b5/3e/9d1ed911db5be8618a2583567488016f23461e6d8e9d564a3a422e8716a5/trsfile-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "66d00e41ed672101e3e0aac872ca1d46", "sha256": "cbf4d858158af31adf17f15d8a4a3e0ca69178d2fee3b66654bf5ff6eca8a70d" }, "downloads": -1, "filename": "trsfile-0.3.1-py3-none-any.whl", "has_sig": false, "md5_digest": "66d00e41ed672101e3e0aac872ca1d46", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 24129, "upload_time": "2019-06-21T14:17:32", "url": "https://files.pythonhosted.org/packages/54/37/482ffc44cbf7ca13eb88490ad0146c2b774201ee11730f375a88396c2857/trsfile-0.3.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "041c407280de7c80e402aaeafca2ede3", "sha256": "e0ece84af6b4fef310e6445c89f261062943cf13521c567d82d4c30655404cc0" }, "downloads": -1, "filename": "trsfile-0.3.1.tar.gz", "has_sig": false, "md5_digest": "041c407280de7c80e402aaeafca2ede3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18153, "upload_time": "2019-06-21T14:17:33", "url": "https://files.pythonhosted.org/packages/35/3b/a68bd00aff1813c0006266aae6f1ae7c02d8b1d67e47851b2d41eb10db41/trsfile-0.3.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "66d00e41ed672101e3e0aac872ca1d46", "sha256": "cbf4d858158af31adf17f15d8a4a3e0ca69178d2fee3b66654bf5ff6eca8a70d" }, "downloads": -1, "filename": "trsfile-0.3.1-py3-none-any.whl", "has_sig": false, "md5_digest": "66d00e41ed672101e3e0aac872ca1d46", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 24129, "upload_time": "2019-06-21T14:17:32", "url": "https://files.pythonhosted.org/packages/54/37/482ffc44cbf7ca13eb88490ad0146c2b774201ee11730f375a88396c2857/trsfile-0.3.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "041c407280de7c80e402aaeafca2ede3", "sha256": "e0ece84af6b4fef310e6445c89f261062943cf13521c567d82d4c30655404cc0" }, "downloads": -1, "filename": "trsfile-0.3.1.tar.gz", "has_sig": false, "md5_digest": "041c407280de7c80e402aaeafca2ede3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18153, "upload_time": "2019-06-21T14:17:33", "url": "https://files.pythonhosted.org/packages/35/3b/a68bd00aff1813c0006266aae6f1ae7c02d8b1d67e47851b2d41eb10db41/trsfile-0.3.1.tar.gz" } ] }