Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Bliss
bliss
Commits
09ca5913
Commit
09ca5913
authored
Jul 01, 2021
by
Perceval Guillou
Browse files
emulate bliss plugin
parent
745ce07e
Changes
2
Hide whitespace changes
Inline
Side-by-side
bliss/config/plugins/bliss_controller.py
View file @
09ca5913
...
...
@@ -53,9 +53,11 @@ def find_sub_names_config(config, selection=None, level=0, parent_key=None):
find_sub_names_config
(
v
,
selection
,
level
+
1
,
k
)
elif
isinstance
(
v
,
(
ConfigList
,
list
)):
if
isinstance
(
v
,
ConfigList
):
rv
=
v
.
raw_list
# !!! raw_items to avoid cyclic import while resolving reference !!!
rv
=
(
v
.
raw_list
)
# !!! raw_items to avoid cyclic import while resolving reference !!!
else
:
rv
=
v
...
...
@@ -453,8 +455,8 @@ def create_objects_from_config_node(cfg_obj, cfg_node):
"""
item_name
=
cfg_node
[
"name"
]
# name of the item that should be created and returned
if
cfg_node
.
plugin
==
"bliss"
:
# act as the older Bliss plugin
if
cfg_node
.
plugin
==
"bliss"
:
# act as the older Bliss plugin
klass
,
node
=
find_class_and_node
(
cfg_node
)
...
...
@@ -521,7 +523,9 @@ def create_objects_from_config_node(cfg_obj, cfg_node):
# --- Now any new object_name going through 'config.get( obj_name )' should call 'create_object_from_cache' only.
# --- 'create_objects_from_config_node' should never be called again for any object related to the container instantiated here (see config.get code)
elif
item_name
==
ctrl_name
:
# allow instantiation of top object which is not a ConfigItemContainer
elif
(
item_name
==
ctrl_name
):
# allow instantiation of top object which is not a ConfigItemContainer
bctrl
=
klass
(
ctrl_node
)
# print(f"=== From config: {item_name} from {bctrl.name} (NOT ConfigItemContainer)")
yield
{
ctrl_name
:
bctrl
}
...
...
bliss/config/static.py
View file @
09ca5913
...
...
@@ -1026,14 +1026,17 @@ class Config(metaclass=Singleton):
if
module_name
is
None
:
module_name
=
"default"
if
module_name
in
[
"emotion"
,
"regulation"
,
"diffractometer"
]:
# , "bliss"
if
module_name
in
[
"emotion"
,
"regulation"
,
"diffractometer"
,
"bliss"
,
]:
# , "bliss"
module_name
=
"bliss_controller"
m
=
__import__
(
"bliss.config.plugins.%s"
%
(
module_name
),
fromlist
=
[
None
])
if
hasattr
(
m
,
"create_object_from_cache"
):
cache_object
=
self
.
_name2cache
.
pop
(
name
,
None
)
# it should be popped only if object instantiation succeed !
cache_object
=
self
.
_name2cache
.
pop
(
name
,
None
)
if
cache_object
is
not
None
:
cache_func
=
getattr
(
m
,
"create_object_from_cache"
)
instance_object
=
cache_func
(
self
,
name
,
cache_object
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment