Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
quality-kpi
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stumpe, Marius
quality-kpi
Commits
cb0147fe
Commit
cb0147fe
authored
2 years ago
by
Hock, Benedikt
Browse files
Options
Downloads
Patches
Plain Diff
add check for correct hierarchy
parent
d7745e50
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
functions/classes.py
+24
-2
24 additions, 2 deletions
functions/classes.py
with
24 additions
and
2 deletions
functions/classes.py
+
24
−
2
View file @
cb0147fe
...
...
@@ -7,6 +7,7 @@ import uuid
from
typing
import
List
,
Dict
import
json
import
copy
import
operator
# TODO
...
...
@@ -184,6 +185,11 @@ class LegoAssembly:
return
clone
def
print_assembly_tree
(
root
,
level
=
0
,
is_last
=
False
):
if
not
isinstance
(
root
,
LegoAssembly
):
raise
TypeError
(
f
"
Argument should be of type
{
LegoAssembly
.
__name__
}
,
"
f
"
got
{
type
(
root
).
__name__
}
instead.
"
)
# print component
assembly_padding
=
""
if
level
>
0
:
...
...
@@ -204,8 +210,24 @@ def print_assembly_tree(root, level=0, is_last=False):
print
(
f
"
{
component_padding
}{
item
}
"
)
def
check_aggregation_hierarchy
(
root
):
pass
def
correct_aggregation_hierarchy
(
root
:
LegoAssembly
,
strict
:
bool
=
False
):
if
not
isinstance
(
root
,
LegoAssembly
):
raise
TypeError
(
f
"
Argument should be of type
{
LegoAssembly
.
__name__
}
,
"
f
"
got
{
type
(
root
).
__name__
}
instead.
"
)
higher_level
=
operator
.
le
if
strict
:
higher_level
=
operator
.
lt
for
component
in
root
.
components
:
if
not
higher_level
(
root
.
layer
.
value
,
component
.
layer
.
value
):
return
False
for
assembly
in
root
.
assemblies
:
if
not
higher_level
(
root
.
layer
.
value
,
assembly
.
layer
.
value
):
return
False
if
not
correct_aggregation_hierarchy
(
assembly
,
strict
):
return
False
return
True
class
KPIEncoder
(
json
.
JSONEncoder
):
...
...
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