org.converters
Attributes
Classes
Base class for protocol classes. |
Functions
|
Takes a dictionary of keywords and encodes them into a somewhat |
|
Decodes keywords creaged by |
Module Contents
- class org.converters.HasKeywords[source]
Bases:
Protocol
Base class for protocol classes.
Protocol classes are defined as:
class Proto(Protocol): def meth(self) -> int: ...
Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).
For example:
class C: def meth(self) -> int: return 0 def func(x: Proto) -> int: return x.meth() func(C()) # Passes static type check
See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:
class GenProto(Protocol[T]): def meth(self) -> T: ...
- org.converters.keywords_encode(keywords: HasKeywords | Mapping[str, Sequence[str]]) str [source]
Takes a dictionary of keywords and encodes them into a somewhat readable url query format.
For example:
{ 'color': ['blue', 'red'], 'weight': ['normal'] }
Results in:
'+color:blue+color:red+weight:normal'
Instead of a dictionary we can also use any kind of object which has a ‘keywords’ property returning the expected dictionary.
Note that that object won’t be recreated during decode however.
- org.converters.keywords_decode(text: str) dict[str, list[str]] | None [source]
Decodes keywords creaged by
keywords_encode()
.