Name | autoroutes JSON |
Version |
0.3.8
JSON |
| download |
home_page | None |
Summary | None |
upload_time | 2025-01-02 11:21:46 |
maintainer | None |
docs_url | None |
author | None |
requires_python | None |
license | MIT License Copyright (c) 2017 Yohan Boniface Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
|
coveralls test coverage |
No coveralls.
|
# Autoroutes
Routes for speed.
## Install
pip install autoroutes
## API
```python
# Create a Routes instance
from autoroutes import Routes
routes = Routes()
# Register a new route
routes.add('path/to/resource/{id}', something='value', anything='else')
# Try to match a route
routes.match('path/to/resource/1234')
> ({'something': 'value', 'anything': 'else'}, {'id': '1234'})
```
Note: the order the routes are registered matters. At match time, routes will be
tried in that order.
### Placeholders
Placeholders are defined by a curly brace pair: `path/{var}`. By default, this
will match any character but the slash ('/').
It's possible to control the placeholder type, either by:
- using a named type: `alnum`, `digit`, `alpha`, `path` (matches everything),
`any` (matches everything, including empty string), `string` (default):
path/to/{var:digit}
path/to/{var:string} # Same as path/to/{var}
- using a normal regex (slower; also note that regex containing curly braces is
not yet supported)
path/to/{var:\d\d\d}
Placeholders can appear anywhere in the path
path/to/file.{ext}
path/to/{name}.{ext}
## Building from source
pip install cython
make compile
python setup.py develop
## Tests
make test
## Benchmark

See [Benchmark](https://github.com/pyrates/autoroutes/wiki/Benchmark) for more
details.
## Acknowledgements
This package has been first made as a Cython port of the [R3](https://github.com/c9s/r3/)
C router.
See also [python-r3](https://framagit.org/ybon/python-r3), which was a first
attempt to wrap R3. I was unhappy with the stability, and more curious about
Cython, so I tried to make a first POC port, and was happy with it.
Raw data
{
"_id": null,
"home_page": null,
"name": "autoroutes",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "Yohan Boniface <yohanboniface@free.fr>",
"download_url": "https://files.pythonhosted.org/packages/f0/43/c0d11db8ca9c05a81b8d7a80d7576f18ca5b381e721c8566cbc27acce1af/autoroutes-0.3.8.tar.gz",
"platform": null,
"description": "# Autoroutes\n\nRoutes for speed.\n\n\n## Install\n\n pip install autoroutes\n\n\n## API\n\n```python\n# Create a Routes instance\nfrom autoroutes import Routes\nroutes = Routes()\n\n# Register a new route\nroutes.add('path/to/resource/{id}', something='value', anything='else')\n\n# Try to match a route\nroutes.match('path/to/resource/1234')\n> ({'something': 'value', 'anything': 'else'}, {'id': '1234'})\n```\n\nNote: the order the routes are registered matters. At match time, routes will be\ntried in that order.\n\n### Placeholders\n\nPlaceholders are defined by a curly brace pair: `path/{var}`. By default, this\nwill match any character but the slash ('/').\n\nIt's possible to control the placeholder type, either by:\n- using a named type: `alnum`, `digit`, `alpha`, `path` (matches everything),\n `any` (matches everything, including empty string), `string` (default):\n\n path/to/{var:digit}\n path/to/{var:string} # Same as path/to/{var}\n\n- using a normal regex (slower; also note that regex containing curly braces is\n not yet supported)\n\n path/to/{var:\\d\\d\\d}\n\nPlaceholders can appear anywhere in the path\n\n path/to/file.{ext}\n path/to/{name}.{ext}\n\n\n## Building from source\n\n pip install cython\n make compile\n python setup.py develop\n\n\n## Tests\n\n make test\n\n## Benchmark\n\n\n\nSee [Benchmark](https://github.com/pyrates/autoroutes/wiki/Benchmark) for more\ndetails.\n\n## Acknowledgements\n\nThis package has been first made as a Cython port of the [R3](https://github.com/c9s/r3/)\nC router.\nSee also [python-r3](https://framagit.org/ybon/python-r3), which was a first\nattempt to wrap R3. I was unhappy with the stability, and more curious about\nCython, so I tried to make a first POC port, and was happy with it.\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2017 Yohan Boniface Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": null,
"version": "0.3.8",
"project_urls": {
"Homepage": "https://github.com/pyrates/autoroutes"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f043c0d11db8ca9c05a81b8d7a80d7576f18ca5b381e721c8566cbc27acce1af",
"md5": "8c2f9b916d638290dcfd10cdb36d4f9f",
"sha256": "4d2b1874f005c7fc33ac65ee29997e55823237239472e1c16b2c9f3a2bcfed38"
},
"downloads": -1,
"filename": "autoroutes-0.3.8.tar.gz",
"has_sig": false,
"md5_digest": "8c2f9b916d638290dcfd10cdb36d4f9f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 119098,
"upload_time": "2025-01-02T11:21:46",
"upload_time_iso_8601": "2025-01-02T11:21:46.472585Z",
"url": "https://files.pythonhosted.org/packages/f0/43/c0d11db8ca9c05a81b8d7a80d7576f18ca5b381e721c8566cbc27acce1af/autoroutes-0.3.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-02 11:21:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pyrates",
"github_project": "autoroutes",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"lcname": "autoroutes"
}