Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
soitool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bachelor-paa-bittet
soitool
Commits
6dd57f95
Commit
6dd57f95
authored
4 years ago
by
Anders H. Rebner
Browse files
Options
Downloads
Patches
Plain Diff
#132 Docstring
parent
c7b9af00
No related branches found
Branches containing commit
No related tags found
1 merge request
!69
#132 Felles funksjon for modul-konstruksjon ved SOI-import
Pipeline
#82641
passed
4 years ago
Stage: lint
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
soitool/serialize_export_import_soi.py
+22
-9
22 additions, 9 deletions
soitool/serialize_export_import_soi.py
with
22 additions
and
9 deletions
soitool/serialize_export_import_soi.py
+
22
−
9
View file @
6dd57f95
...
...
@@ -235,8 +235,9 @@ def construct_soi_from_serialized(serialized, compressed=False):
if
not
SERIALIZED_SOI_SCHEMA
.
is_valid
(
serialized
):
raise
ValueError
(
"
Serialized SOI does not have correct format.
"
)
modules
=
construct_modules
(
serialized
)
attachments
=
construct_modules
(
serialized
,
is_modules
=
False
)
# Construct modules and attachments
modules
=
construct_modules_from_serialized
(
serialized
[
"
modules
"
])
attachments
=
construct_modules_from_serialized
(
serialized
[
"
attachments
"
])
# Create SOI
soi
=
SOI
(
...
...
@@ -260,14 +261,26 @@ def construct_soi_from_serialized(serialized, compressed=False):
return
soi
def
construct_modules
(
serialized
,
is_modules
=
True
):
"""
...
"""
def
construct_modules_from_serialized
(
serialized_modules
):
"""
Instantiate modules from serialized format.
Parameters
----------
serialized_modules : list
list of dicts containing serialized modules or attachment-modules.
Returns
-------
list
Containing instantiated modules or attachment-modules.
Raises
------
TypeError
If type of module is not recognized.
"""
# Create dict for modules with instantiated widget(s)
modules
=
[]
if
is_modules
:
serialized_modules
=
serialized
[
"
modules
"
]
else
:
serialized_modules
=
serialized
[
"
attachments
"
]
for
module
in
serialized_modules
:
module_type
=
module
[
"
type
"
]
...
...
@@ -300,7 +313,7 @@ def construct_modules(serialized, is_modules=True):
size
=
module
[
"
size
"
]
data
=
module
[
"
data
"
]
modules
.
append
(
{
"
widget
"
:
FreeTextModule
(
size
,
data
),
"
meta
"
:
module
[
"
meta
"
]
,
}
{
"
widget
"
:
FreeTextModule
(
size
,
data
),
"
meta
"
:
module
[
"
meta
"
]}
)
else
:
raise
TypeError
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment