Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.editor
Commits
44ea95e7
Commit
44ea95e7
authored
Oct 02, 2019
by
Samuel GAIST
Browse files
[widgets][plotterparameterseditor] Make resistant to "empty" JSON
Empty as in "{}"
parent
faab3c71
Changes
1
Hide whitespace changes
Inline
Side-by-side
beat/editor/widgets/plotterparameterseditor.py
View file @
44ea95e7
...
...
@@ -125,12 +125,6 @@ class RestrictedParameterWidget(QWidget):
self
.
_type
=
data
.
get
(
"type"
,
None
)
self
.
default
=
data
.
get
(
"default"
,
None
)
if
self
.
_type
is
None
:
raise
RuntimeError
(
"Invalid parameter with no type"
)
if
self
.
default
is
None
:
raise
RuntimeError
(
"Invalid parameter with no default"
)
self
.
current_type
=
InputType
[
self
.
_type
.
upper
()]
self
.
modality
=
"single"
if
"choice"
in
data
:
...
...
@@ -233,10 +227,7 @@ class RestrictedParameterWidget(QWidget):
def
__set_choice_default_value
(
self
,
default_value
):
index
=
self
.
choices_combobox
.
findText
(
default_value
,
Qt
.
MatchFixedString
)
if
index
>=
0
:
self
.
choices_combobox
.
setCurrentIndex
(
index
)
else
:
raise
RuntimeError
(
"Invalid default value"
)
self
.
choices_combobox
.
setCurrentIndex
(
index
)
class
PlotterParameterViewer
(
QWidget
):
...
...
@@ -429,13 +420,17 @@ class PlotterParametersEditor(AbstractAssetEditor):
# Fetch plotter json data
asset
=
Asset
(
self
.
plotter_model
.
prefix_path
,
self
.
plotter_model
.
asset_type
,
selected_plotter
,
)
if
selected_plotter
:
asset
=
Asset
(
self
.
plotter_model
.
prefix_path
,
self
.
plotter_model
.
asset_type
,
selected_plotter
,
)
self
.
plotter_json_data
=
asset
.
declaration
self
.
plotter_json_data
=
asset
.
declaration
else
:
self
.
plotter_json_data
=
{}
while
self
.
parameter_viewers
:
widget
=
self
.
parameter_viewers
[
0
]
...
...
@@ -461,16 +456,9 @@ class PlotterParametersEditor(AbstractAssetEditor):
self
.
blockSignals
(
True
)
selected_plotter
=
json_object
.
get
(
"plotter"
,
None
)
if
selected_plotter
is
None
:
raise
RuntimeError
(
"Invalid plotterparameter with no defined plotter"
)
selected_plotter
=
json_object
.
get
(
"plotter"
)
index
=
self
.
plotter_combobox
.
findText
(
selected_plotter
,
Qt
.
MatchFixedString
)
if
index
>=
0
:
self
.
plotter_combobox
.
setCurrentIndex
(
index
)
else
:
raise
RuntimeError
(
"Invalid default value"
)
self
.
plotter_combobox
.
setCurrentIndex
(
index
)
self
.
__load_parameter
(
json_object
)
...
...
@@ -498,9 +486,7 @@ class PlotterParametersEditor(AbstractAssetEditor):
self
.
scroll_widget
.
clear
()
selected_plotter
=
json_object
.
get
(
"plotter"
,
None
)
if
selected_plotter
is
None
:
raise
RuntimeError
(
"Invalid plotterparameter with no defined plotter"
)
selected_plotter
=
json_object
.
get
(
"plotter"
)
self
.
__fetch_load_plotter_data
(
selected_plotter
)
...
...
Write
Preview
Supports
Markdown
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