Commit b004ab53 authored by Sebastien Petitdemange's avatar Sebastien Petitdemange
Browse files

Merge branch 'config_refs_fixes' into 'master'

Config. refs fixes

See merge request !436
parents 3f2a3b18 1bf294f0
......@@ -37,7 +37,7 @@ def _checkref(config,item_cfg_node,referenced_objects,name,value):
def _parse_dict(config,item_cfg_node,referenced_objects,
subdict):
for name,node in subdict.iteritems():
if _checkref(config,item_cfg_node,referenced_objects,
if _checkref(config,subdict,referenced_objects,
name,node):
continue
elif isinstance(node,dict):
......@@ -57,7 +57,7 @@ def _parse_dict(config,item_cfg_node,referenced_objects,
def _parse_list(config,value):
object_list = list()
for node in value:
if isinstance(node,str) and node.startswith("$"):
if isinstance(node,(str,unicode)) and node.startswith("$"):
object_list.append(weakref.proxy(config.get(node)))
elif isinstance(node,dict):
subdict = dict()
......@@ -92,3 +92,4 @@ def replace_reference_by_object(config,item_cfg_node,ref_objects = None):
if subref:
referenced_objects[name] = subref
item_cfg_node.update(subdict)
......@@ -54,3 +54,17 @@ def test_config_save(beacon):
rw_cfg2.save()
def test_references(beacon):
refs_cfg = beacon.get("refs_test")
m0 = beacon.get("m0")
s1hg = beacon.get("s1hg")
s1vo = beacon.get("s1vo")
assert refs_cfg['scan']['axis'].__repr__() == repr(m0)
assert refs_cfg['slits'][0]['axis'].__repr__() == repr(s1hg)
assert refs_cfg['slits'][0]['position'] == 0
assert refs_cfg['slits'][1]['axis'].__repr__() == repr(s1vo)
assert refs_cfg['slits'][1]['position'] == 1
assert refs_cfg['m0'].__repr__() == repr(m0)
plugin: default
name: refs_test
m0: $m0
slits:
- axis: $s1hg
position: 0
- axis: $s1vo
position: 1
scan:
axis: $m0
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