{ "info": { "author": "xtao", "author_email": "xutao881001@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# Scanner\n[![Build Status](https://travis-ci.org/cuteio/scanner.png?branch=master)](https://travis-ci.org/cuteio/scanner) \nScanner provides for lexical scanning operations on a String. Clone of [Ruby's StringScanner](http://ruby-doc.org/stdlib-2.0.0/libdoc/strscan/rdoc/StringScanner.html). \n\nHere is an example of its usage:\n\n```\nfrom scanner import StringScanner, StringRegexp\ns = StringScanner('This is an example string')\ns.is_eos # -> False\n\nprint s.scan(StringRegexp('\\w+')) # -> \"This\"\nprint s.scan(StringRegexp('\\w+')) # -> None\nprint s.scan(StringRegexp('\\s+')) # -> \" \"\nprint s.scan(StringRegexp('\\s+')) # -> None\nprint s.scan(StringRegexp('\\w+')) # -> \"is\"\ns.is_eos # -> False\n\nprint s.scan(StringRegexp('\\s+')) # -> \" \"\nprint s.scan(StringRegexp('\\w+')) # -> \"an\"\nprint s.scan(StringRegexp('\\s+')) # -> \" \"\nprint s.scan(StringRegexp('\\w+')) # -> \"example\"\nprint s.scan(StringRegexp('\\s+')) # -> \" \"\nprint s.scan(StringRegexp('\\w+')) # -> \"string\"\ns.is_eos # -> True\n\nprint s.scan(StringRegexp('\\s+')) # -> nil\nprint s.scan(StringRegexp('\\w+')) # -> nil\n```\n\nScanning a string means remembering the position of a scan pointer, which is just an index. The point of scanning is to move forward a bit at a time, so matches are sought after the scan pointer; usually immediately after it.\n\nGiven the string \"test string\", here are the pertinent scan pointer positions:\n\n```\n t e s t s t r i n g\n0 1 2 ... 1\n 0\n```\n\nWhen you scan for a pattern (a regular expression), the match must occur at the character after the scan pointer. If you use scan_until, then the match can occur anywhere after the scan pointer. In both cases, the scan pointer moves just beyond the last character of the match, ready to scan again from the next character onwards. This is demonstrated by the example above.\n\n\nThere are other methods besides the plain scanners. You can look ahead in the string without actually scanning. You can access the most recent match. You can modify the string being scanned, reset or terminate the scanner, find out or change the position of the scan pointer, skip ahead, and so on.\n\n#### Advancing the Scan Pointer\n\n```\ngetch\nget_byte\nscan\nscan_until\nskip\nskip_until\n```\n\n#### Looking Ahead\n\n```\ncheck\ncheck_until\nexists\npeek\n```\n\n#### Finding Where we Are\n\n```\nis_bol (beginning_of_line?)\nis_eos\nis_rest\nrest_size\npos\n```\n\n#### Setting Where we Are\n\n```\nreset\nterminate\npos=\n```\n\n####Match Data\n\n```\nmatched\nis_matched\nmatched_size\npre_match\npost_match\n```\n\n#### Miscellaneous\n\n```\nconcat\nstring\nstring=\nunscan\n```\n\n### Changelog\n\n__v0.0.5[2014-02-07]__\n* Fix the setter prototype and return value \n\n__v0.0.4[2013-11-19]__\n* Fix Python 2.7.3 `Segmentation fault`.\n\n__v0.0.3[2013-11-17]__\n\n__v0.0.2[2013-11-17]__\n* It's worked.\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/liluo/scanner", "keywords": "scanner StringScanner", "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "scanner", "package_url": "https://pypi.org/project/scanner/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/scanner/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/liluo/scanner" }, "release_url": "https://pypi.org/project/scanner/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "Scanner is like Ruby's StringScanner", "version": "0.1.0" }, "last_serial": 2277442, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "2f0d8ef82f1100660c0755e3f5ea7487", "sha256": "82f36821f4ce1bec0e72b02d9f1583a11ee326dfb0df2c6edc12518c1dee1cdd" }, "downloads": -1, "filename": "scanner-0.0.2.tar.gz", "has_sig": false, "md5_digest": "2f0d8ef82f1100660c0755e3f5ea7487", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 575179, "upload_time": "2013-11-17T16:00:26", "url": "https://files.pythonhosted.org/packages/e1/85/9246ed15d26037e7276ed065621ec635d6fcb8cb65a31ed8c7ca3d046be2/scanner-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "7bb6bc9c2482f9888d974d8d82bdbb80", "sha256": "1bc6c2e5126d01a8ecda1a4a148eb7363a4dcc2817eb4ac44ec0a5a9fde47363" }, "downloads": -1, "filename": "scanner-0.0.3.tar.gz", "has_sig": false, "md5_digest": "7bb6bc9c2482f9888d974d8d82bdbb80", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 575145, "upload_time": "2013-11-18T07:48:25", "url": "https://files.pythonhosted.org/packages/63/fd/c8fa4bcd9bb3f91062fd04720553e19452c9bca390e3524baef0041bd072/scanner-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "80aa92c010c1ae6d1eb3ec13ffd056ca", "sha256": "74ae544c7390f2c27f5e8e70526966a9bc9f9110cc8151d2a25265770f0ef042" }, "downloads": -1, "filename": "scanner-0.0.4.tar.gz", "has_sig": false, "md5_digest": "80aa92c010c1ae6d1eb3ec13ffd056ca", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 575186, "upload_time": "2013-11-19T14:55:39", "url": "https://files.pythonhosted.org/packages/08/9c/5008e4747cb2d3d30fc6fd6a6bf49087c7afda131af9046c97a234642f02/scanner-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "255460c15ee4e51515eb339a619217a4", "sha256": "d94f221a40f16515ee6826139b2f4e7aa3fadf6f993bd443b8a08b671dc82764" }, "downloads": -1, "filename": "scanner-0.0.5.tar.gz", "has_sig": false, "md5_digest": "255460c15ee4e51515eb339a619217a4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 575224, "upload_time": "2014-02-07T03:16:35", "url": "https://files.pythonhosted.org/packages/44/74/a4c896efe902ac8248ac17fd81c392f976e743bb4b02ad7d202c2ae5fd1b/scanner-0.0.5.tar.gz" } ], "0.01": [], "0.1.0": [ { "comment_text": "", "digests": { "md5": "ccd1247cdbb088274a36e20100e9fb36", "sha256": "8bffaa1861c908d83728538cf00434c005c8bf36414ab708f3c822afd881bef7" }, "downloads": -1, "filename": "scanner-0.1.0.tar.gz", "has_sig": false, "md5_digest": "ccd1247cdbb088274a36e20100e9fb36", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 575628, "upload_time": "2016-08-12T05:24:03", "url": "https://files.pythonhosted.org/packages/00/4c/9b8810330fad60678944d73421ab6d476453fad105cce7570ceb1fbdc9e1/scanner-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ccd1247cdbb088274a36e20100e9fb36", "sha256": "8bffaa1861c908d83728538cf00434c005c8bf36414ab708f3c822afd881bef7" }, "downloads": -1, "filename": "scanner-0.1.0.tar.gz", "has_sig": false, "md5_digest": "ccd1247cdbb088274a36e20100e9fb36", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 575628, "upload_time": "2016-08-12T05:24:03", "url": "https://files.pythonhosted.org/packages/00/4c/9b8810330fad60678944d73421ab6d476453fad105cce7570ceb1fbdc9e1/scanner-0.1.0.tar.gz" } ] }