Added support for generic kwargs to publish_entities.

This commit is contained in:
Fabio Manganiello 2023-11-23 01:04:37 +01:00
parent ca7c89949b
commit 841a28066b
Signed by: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -34,7 +34,7 @@ class EntityManager(ABC):
return super().__new__(cls) return super().__new__(cls)
@abstractmethod @abstractmethod
def transform_entities(self, entities: Collection[Any]) -> Collection[Entity]: def transform_entities(self, entities: Collection[Any], **_) -> Collection[Entity]:
""" """
This method takes a list of entities in any (plugin-specific) This method takes a list of entities in any (plugin-specific)
format and converts them into a standardized collection of format and converts them into a standardized collection of
@ -86,6 +86,7 @@ class EntityManager(ABC):
self, self,
entities: Optional[Collection[Any]], entities: Optional[Collection[Any]],
callback: Optional[EntitySavedCallback] = None, callback: Optional[EntitySavedCallback] = None,
**kwargs,
) -> Collection[Entity]: ) -> Collection[Entity]:
""" """
Publishes a list of entities. The downstream consumers include: Publishes a list of entities. The downstream consumers include:
@ -106,7 +107,7 @@ class EntityManager(ABC):
from platypush.entities import publish_entities from platypush.entities import publish_entities
transformed_entities = self._normalize_entities( transformed_entities = self._normalize_entities(
self.transform_entities(entities or []) self.transform_entities(entities or [], **kwargs)
) )
publish_entities(transformed_entities, callback=callback) publish_entities(transformed_entities, callback=callback)