This release is a pre-release and may not be stable for production use.
SILVANUS
The simple library for different routing with a tree-like structure
Implementation example
Silvanus is created as a low-level library that simplifies the construction of productive, user-friendly, functional and customizable frameworks on top of. These can be different options (data buses, web, etc.), therefore, for an example of how it might look, there is silvahttp.
Paradigms:
- Each element is changeable almost beyond recognition, but a combination of them is possible due to common protocols that are well described out of the box.
- Many things are done out of the box (for example, the almost universal SimpleRouter and its two RouterIterators, which implement both the data queue interface with filters and the data bus interface with filters )
- The most universal protocols, which is why it is recommended to write small wrappers on top of routing for frameworks.
Usage
First:
pip install silvanus
Later:
data queue interface with filters using FirstTrueRouterIterator, and data bus interface with filters using AllTrueRouterIterator
import asyncio
from dataclasses import dataclass
from silvanus.routing.simple import SimpleRouter
from silvanus.strategy.routers import FirstTrueRouterIterator, AllTrueRouterIterator
from silvanus.structures import RoutingData
@dataclass(frozen=True)
class SimpleFilter: # Our custom simple filter
value: int
async def __call__(self, data: RoutingData) -> bool:
return data.request_data.get("value", None) == self.value
# silvanus supports all data types as a result of routing,
# but the most useful for frameworks will be the return of functions.
def some_handler(text: str) -> str:
return text * 2
router = SimpleRouter()
router1 = SimpleRouter([SimpleFilter(value=10)], data="wrong")
router2 = SimpleRouter([SimpleFilter(value=15), ], data=some_handler)
router3 = SimpleRouter([SimpleFilter(value=15), ], data="yes!")
router.add_routers([router1, router2, router3])
async def main():
result = await router.route(
data=RoutingData(
request_data={"value": 15}
),
iterator=FirstTrueRouterIterator() # get only first True result
)
assert result("silvanus-") == "silvanus-silvanus-" # our some_handler
result_2 = await router.route(
data=RoutingData(
request_data={"value": 15}
),
iterator=AllTrueRouterIterator() # get all True result
)
assert result_2[0](result_2[1]) == "yes!yes!" # our some_handler and text from second data
asyncio.run(main())
Examples:
Metadata
Release files for silvanus 0.1.1b1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| silvanus-0.1.1b1.tar.gz | 5.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| silvanus-0.1.1b1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.1 kB
Release files / silvanus-0.1.1b1.tar.gz
| Download URL | silvanus-0.1.1b1.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
226c9dc6acc241e7c26dfbaa5d85cd87b9a4871a33b2d282e3be9d4a1ce409e9
|
|
BLAKE2b-256 checksum How to use checksums |
0f5d9c40813f1606894d9dccce611a5d3d6e6cff84b2de914b463bfe14a34379
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.13.5 Darwin/25.0.0
|
Release files / silvanus-0.1.1b1-py3-none-any.whl
| Download URL | silvanus-0.1.1b1-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d4404988a7b83555edfd573c1fa878ae2fdb58154ae4fc897543d59a067cb842
|
|
BLAKE2b-256 checksum How to use checksums |
1ac2905b00dcf2641de9535cd9f7e1fa5e69281591b7b43d27af5d142d1bbbf6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.13.5 Darwin/25.0.0
|
Security for silvanus 0.1.1b1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.