Commit 14b7728a authored by Piergiorgio Pancino's avatar Piergiorgio Pancino
Browse files

fix on beacon_object

parent b0c81f13
......@@ -14,46 +14,7 @@ from bliss.common import event
from bliss.common.utils import Null, autocomplete_property
from bliss.config.conductor.client import remote_open
from bliss.config.static import Node
from bliss.config.static import get_config_dict
def _find_dict(name, d):
if d.get("name") == name:
return d
for key, value in d.items():
if isinstance(value, dict):
sub_dict = _find_dict(name, value)
elif isinstance(value, list):
sub_dict = _find_list(name, value)
else:
continue
if sub_dict is not None:
return sub_dict
def _find_list(name, l):
for value in l:
if isinstance(value, dict):
sub_dict = _find_dict(name, value)
elif isinstance(value, list):
sub_dict = _find_list(name, value)
else:
continue
if sub_dict is not None:
return sub_dict
def _find_subconfig(d, path):
_NotProvided = type("_NotProvided", (), {})()
path = path.copy()
key = path.pop(0)
sub = d.get(key, _NotProvided)
if sub == _NotProvided:
return Node()
if len(path) > 0:
return _find_subconfig(sub, path)
return sub
from bliss.config.static import get_config_dict, _find_list, _find_dict, _find_subconfig
class BeaconObject:
......
......@@ -62,6 +62,45 @@ from bliss.config import channels
CONFIG = None
def _find_dict(name, d):
if d.get("name") == name:
return d
for key, value in d.items():
if isinstance(value, dict):
sub_dict = _find_dict(name, value)
elif isinstance(value, list):
sub_dict = _find_list(name, value)
else:
continue
if sub_dict is not None:
return sub_dict
def _find_list(name, l):
for value in l:
if isinstance(value, dict):
sub_dict = _find_dict(name, value)
elif isinstance(value, list):
sub_dict = _find_list(name, value)
else:
continue
if sub_dict is not None:
return sub_dict
def _find_subconfig(d, path):
_NotProvided = type("_NotProvided", (), {})()
path = path.copy()
key = path.pop(0)
sub = d.get(key, _NotProvided)
if sub == _NotProvided:
return Node()
if len(path) > 0:
return _find_subconfig(sub, path)
return sub
class BlissYamlResolver(Resolver):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment