forked from platypush/platypush
Filter by configured/enabled plugins when returning the entity/plugin registry
This commit is contained in:
parent
3b4f7d3dad
commit
948f37afd4
1 changed files with 16 additions and 1 deletions
|
@ -2,6 +2,7 @@ import json
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Optional, Dict, Collection, Type
|
from typing import Optional, Dict, Collection, Type
|
||||||
|
|
||||||
|
from platypush.config import Config
|
||||||
from platypush.plugins import Plugin
|
from platypush.plugins import Plugin
|
||||||
from platypush.utils import get_plugin_name_by_class, get_redis
|
from platypush.utils import get_plugin_name_by_class, get_redis
|
||||||
|
|
||||||
|
@ -30,10 +31,24 @@ def get_plugin_entity_registry() -> Dict[str, Dict[str, Collection[str]]]:
|
||||||
redis = get_redis()
|
redis = get_redis()
|
||||||
registry = redis.mget([_entity_registry_varname])[0]
|
registry = redis.mget([_entity_registry_varname])[0]
|
||||||
try:
|
try:
|
||||||
return json.loads((registry or b'').decode())
|
registry = json.loads((registry or b'').decode())
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
return {'by_plugin': {}, 'by_entity_type': {}}
|
return {'by_plugin': {}, 'by_entity_type': {}}
|
||||||
|
|
||||||
|
enabled_plugins = set(Config.get_plugins().keys())
|
||||||
|
|
||||||
|
return {
|
||||||
|
'by_plugin': {
|
||||||
|
plugin_name: entity_types
|
||||||
|
for plugin_name, entity_types in registry['by_plugin'].items()
|
||||||
|
if plugin_name in enabled_plugins
|
||||||
|
},
|
||||||
|
'by_entity_type': {
|
||||||
|
entity_type: [p for p in plugins if p in enabled_plugins]
|
||||||
|
for entity_type, plugins in registry['by_entity_type'].items()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class EntityManagerMixin:
|
class EntityManagerMixin:
|
||||||
def transform_entities(self, entities):
|
def transform_entities(self, entities):
|
||||||
|
|
Loading…
Reference in a new issue