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
Quiring, Ole
quality-kpi
Commits
7f9ef658
Commit
7f9ef658
authored
2 years ago
by
Hock, Martin
Browse files
Options
Downloads
Patches
Plain Diff
rename name to label to make merge easier
parent
acd86242
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
+11
-11
11 additions, 11 deletions
functions/classes.py
with
11 additions
and
11 deletions
functions/classes.py
+
11
−
11
View file @
7f9ef658
...
@@ -29,13 +29,13 @@ class AggregationLayer(Enum):
...
@@ -29,13 +29,13 @@ class AggregationLayer(Enum):
class
LegoComponent
:
class
LegoComponent
:
def
__init__
(
self
,
name
:
Optional
[
str
]
=
None
,
datasheet
:
Optional
[
dict
]
=
None
,
*
more_properties
:
dict
,
**
kwargs
)
->
None
:
def
__init__
(
self
,
label
:
Optional
[
str
]
=
None
,
datasheet
:
Optional
[
dict
]
=
None
,
*
more_properties
:
dict
,
**
kwargs
)
->
None
:
self
.
uuid
:
uuid
.
UUID
=
uuid
.
uuid4
()
self
.
uuid
:
uuid
.
UUID
=
uuid
.
uuid4
()
self
.
parent
:
None
|
LegoAssembly
=
None
self
.
parent
:
None
|
LegoAssembly
=
None
self
.
layer
:
AggregationLayer
=
AggregationLayer
.
COMPONENT
self
.
layer
:
AggregationLayer
=
AggregationLayer
.
COMPONENT
self
.
properties
:
dict
=
{}
self
.
properties
:
dict
=
{}
if
name
is
not
None
:
if
label
is
not
None
:
self
.
properties
[
'
name
'
]
=
name
self
.
properties
[
'
label
'
]
=
label
if
datasheet
is
not
None
:
if
datasheet
is
not
None
:
self
.
properties
.
update
(
datasheet
)
self
.
properties
.
update
(
datasheet
)
self
.
properties
[]
self
.
properties
[]
...
@@ -68,7 +68,7 @@ class LegoComponent:
...
@@ -68,7 +68,7 @@ class LegoComponent:
def
to_dict
(
self
)
->
Dict
:
def
to_dict
(
self
)
->
Dict
:
ATTRIBUTES
=
[
ATTRIBUTES
=
[
"
uuid
"
,
"
uuid
"
,
"
name
"
,
"
label
"
,
"
category
"
,
"
category
"
,
"
lego_id
"
,
"
lego_id
"
,
"
cost
"
,
"
cost
"
,
...
@@ -96,16 +96,16 @@ class LegoComponent:
...
@@ -96,16 +96,16 @@ class LegoComponent:
# TODO good repr representation
# TODO good repr representation
def
__repr__
(
self
):
def
__repr__
(
self
):
return
f
"
LegoComponent
{
self
.
properties
[
'
name
'
]
}
[
{
self
.
uuid
}
]
"
return
f
"
LegoComponent
{
self
.
properties
[
'
label
'
]
}
[
{
self
.
uuid
}
]
"
class
LegoAssembly
:
class
LegoAssembly
:
def
__init__
(
self
,
layer
:
AggregationLayer
,
name
:
Optional
[
str
]
=
None
,
*
properties
:
dict
,
**
kwargs
)
->
None
:
def
__init__
(
self
,
layer
:
AggregationLayer
,
label
:
Optional
[
str
]
=
None
,
*
properties
:
dict
,
**
kwargs
)
->
None
:
self
.
uuid
:
uuid
.
UUID
=
uuid
.
uuid4
()
self
.
uuid
:
uuid
.
UUID
=
uuid
.
uuid4
()
self
.
parent
:
None
|
LegoAssembly
=
None
self
.
parent
:
None
|
LegoAssembly
=
None
self
.
properties
:
dict
=
{}
self
.
properties
:
dict
=
{}
if
name
is
not
None
:
if
label
is
not
None
:
self
.
properties
[
'
name
'
]
=
name
self
.
properties
[
'
label
'
]
=
label
self
.
layer
:
AggregationLayer
=
layer
self
.
layer
:
AggregationLayer
=
layer
self
.
properties
.
update
(
properties
)
self
.
properties
.
update
(
properties
)
self
.
components
:
List
[
LegoComponent
]
=
[]
self
.
components
:
List
[
LegoComponent
]
=
[]
...
@@ -172,7 +172,7 @@ class LegoAssembly:
...
@@ -172,7 +172,7 @@ class LegoAssembly:
return
False
return
False
def
to_dict
(
self
)
->
Dict
:
def
to_dict
(
self
)
->
Dict
:
ATTRIBUTES
=
[
"
uuid
"
,
"
name
"
,
"
layer
"
,
"
properties
"
]
ATTRIBUTES
=
[
"
uuid
"
,
"
label
"
,
"
layer
"
,
"
properties
"
]
dict_
=
{}
dict_
=
{}
# store attributes
# store attributes
for
attr
in
ATTRIBUTES
:
for
attr
in
ATTRIBUTES
:
...
@@ -185,7 +185,7 @@ class LegoAssembly:
...
@@ -185,7 +185,7 @@ class LegoAssembly:
# TODO find good string representation
# TODO find good string representation
def
__repr__
(
self
):
def
__repr__
(
self
):
return
f
"
LegoAssembly
{
self
.
properties
[
'
name
'
]
}
[
{
self
.
uuid
}
]
"
return
f
"
LegoAssembly
{
self
.
properties
[
'
label
'
]
}
[
{
self
.
uuid
}
]
"
def
print_assembly_tree
(
root
,
level
=
0
,
is_last
=
False
):
def
print_assembly_tree
(
root
,
level
=
0
,
is_last
=
False
):
...
@@ -214,5 +214,5 @@ class KPIEncoder(json.JSONEncoder):
...
@@ -214,5 +214,5 @@ class KPIEncoder(json.JSONEncoder):
if
isinstance
(
o
,
uuid
.
UUID
):
if
isinstance
(
o
,
uuid
.
UUID
):
return
"
kpi-
"
+
str
(
o
)
return
"
kpi-
"
+
str
(
o
)
if
isinstance
(
o
,
(
AggregationLayer
)):
if
isinstance
(
o
,
(
AggregationLayer
)):
return
"
kpi-
"
+
o
.
name
return
"
kpi-
"
+
o
.
label
return
super
().
default
(
o
)
return
super
().
default
(
o
)
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