A simple router / treelib for python.
Project description
SimpleRoute
A simple router / treelib for python.
Usage
Installation
pip install simpleroute
Import
Note: as simpleroute uses two dictionaries internally rather than an OOP-based node system,
Traverse replaces the standard "Node" class present in most other tree libraries.
from simpleroute import BaseRouter, Router, Traverse
Classes
router = BaseRouter([]) # list of paths sep by /
path, kwargs = router.match("SOME_STR_HERE") #match wildcards, eg /etc/1 to /etc/:num
router = Router({}) # dict of paths:datavals sep by /
path, kwargs, data = router.match("SOME_STR_HERE") #match wildcards, eg /etc/1 to /etc/:num
traverse = Traverse.go(router, path="SOME_PATH_HERE") #returns an object of Traverse, optional path to go
#use get_child, get_children, get_parent, get_data, get_path, get_sub to manipulate the object
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
simpleroute-0.0.2.tar.gz
(8.6 kB
view hashes)
Built Distribution
Close
Hashes for simpleroute-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2be8338d1081d992cb5f161841b4c80c5ff0408ebb7468146e539419a6cb0075 |
|
MD5 | bcefc771f7e7ed5c0c2913c077fe99bb |
|
BLAKE2b-256 | d0608df8675d119aee7480eb09c7d0f7eef15bdbfb3daebfdec8cb71bea7fc7d |