This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""The truth is, I thought it mattered -- | |
I thought that music mattered. | |
But does it bollocks? | |
Not compared to how people matter. | |
""" | |
from itertools import cycle, repeat | |
from operator import methodcaller | |
from typing import List |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Callable, Hashable | |
class FuncRegistry(dict): | |
"""Creates a registry of hashable objects to function mappings.""" | |
def __init__(self, *args, **kwargs): | |
super().__init__(*args, **kwargs) | |
def register_for(self, key: Hashable) -> Callable: | |
"""Decorator to register functions in the registry. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Objects that facilitate parsing values from regex and assigning | |
those values to other objects. | |
Classes | |
Val: | |
Object that stores the group matches from an re.match() call. | |
Class methods that change the stored value are chainable. | |
Functions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Helper class to run a chain of callbacks on input data.""" | |
from typing import Callable, Any | |
class CbChain(object): | |
"""Chain callbacks together. | |
Instances of this object are themselves Callable. When called, it passes the supplied arguments to the first | |
callback in the chain. The result of the first callback is fed to the second, the result of the second fed to | |
the third, and so on. |