[docs]classMethods:"""A class used to hold the accessor methods for a particular data type. Parameters ---------- stream : "Stream" The stream to injected with the method accessor. """def__init__(self,stream:"Stream"):self.stream=stream@classmethoddef_make_accessor(cls,stream:"Stream"):returncls(stream)
[docs]@classmethoddefregister_method(cls,func:Callable,names:"List[str]"):"""Injects an accessor into a specific stream instance. Parameters ---------- func : `Callable` The function to be injected as an accessor method. names : `List[str]` The names to be given to the function. """defmethod(self,*args,**kwargs):args=(self.stream,)+argsreturnfunc(*args,**kwargs)fornameinnames:setattr(cls,name,method)returnmethod