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
c7b9af00
Commit
c7b9af00
authored
4 years ago
by
Anders H. Rebner
Browse files
Options
Downloads
Patches
Plain Diff
#132 Felles funksjon for modul-konstruksjon
parent
9875c45d
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
#82640
failed
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
+35
-40
35 additions, 40 deletions
soitool/serialize_export_import_soi.py
with
35 additions
and
40 deletions
soitool/serialize_export_import_soi.py
+
35
−
40
View file @
c7b9af00
...
...
@@ -235,9 +235,41 @@ 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
)
# Create SOI
soi
=
SOI
(
serialized
[
"
title
"
],
serialized
[
"
description
"
],
serialized
[
"
version
"
],
serialized
[
"
date
"
],
serialized
[
"
valid
"
][
"
from_date
"
],
serialized
[
"
valid
"
][
"
to_date
"
],
serialized
[
"
icon
"
],
serialized
[
"
classification
"
],
serialized
[
"
orientation
"
],
serialized
[
"
placement_strategy
"
],
serialized
[
"
algorithm_bin
"
],
serialized
[
"
algorithm_pack
"
],
serialized
[
"
algorithm_sort
"
],
modules
,
attachments
,
)
return
soi
def
construct_modules
(
serialized
,
is_modules
=
True
):
"""
...
"""
# Create dict for modules with instantiated widget(s)
modules
=
[]
for
module
in
serialized
[
"
modules
"
]:
if
is_modules
:
serialized_modules
=
serialized
[
"
modules
"
]
else
:
serialized_modules
=
serialized
[
"
attachments
"
]
for
module
in
serialized_modules
:
module_type
=
module
[
"
type
"
]
if
module_type
==
"
TableModule
"
:
...
...
@@ -268,51 +300,14 @@ def construct_soi_from_serialized(serialized, compressed=False):
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
(
"
Module-type
'
{}
'
is not recognized.
"
.
format
(
module_type
)
)
# Create dict for attachments with instantiated widget(s)
attachments
=
[]
for
attachment
in
serialized
[
"
attachments
"
]:
module_type
=
attachment
[
"
type
"
]
if
module_type
==
"
TableModule
"
:
size
=
attachment
[
"
size
"
]
data
=
attachment
[
"
data
"
]
attachments
.
append
(
{
"
widget
"
:
TableModule
(
size
,
data
),
"
meta
"
:
attachment
[
"
meta
"
],
}
)
else
:
raise
TypeError
(
"
Module-type
'
{}
'
is not recognized.
"
.
format
(
module_type
)
)
# Create SOI
soi
=
SOI
(
serialized
[
"
title
"
],
serialized
[
"
description
"
],
serialized
[
"
version
"
],
serialized
[
"
date
"
],
serialized
[
"
valid
"
][
"
from_date
"
],
serialized
[
"
valid
"
][
"
to_date
"
],
serialized
[
"
icon
"
],
serialized
[
"
classification
"
],
serialized
[
"
orientation
"
],
serialized
[
"
placement_strategy
"
],
serialized
[
"
algorithm_bin
"
],
serialized
[
"
algorithm_pack
"
],
serialized
[
"
algorithm_sort
"
],
modules
,
attachments
,
)
return
soi
return
modules
def
generate_soi_filename
(
soi
):
...
...
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