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
94f541d0
Commit
94f541d0
authored
2 years ago
by
Hock, Martin
Browse files
Options
Downloads
Patches
Plain Diff
Remove unreached code, use black formatter
parent
4646326a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
functions/classes.py
+25
-16
25 additions, 16 deletions
functions/classes.py
with
25 additions
and
16 deletions
functions/classes.py
+
25
−
16
View file @
94f541d0
...
...
@@ -7,6 +7,7 @@ import uuid
from
typing
import
List
,
Dict
,
Optional
import
json
class
AggregationLayer
(
Enum
):
SYSTEM
=
auto
()
ASSEMBLY
=
auto
()
...
...
@@ -15,13 +16,19 @@ class AggregationLayer(Enum):
class
LegoComponent
:
def
__init__
(
self
,
label
:
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
.
parent
:
None
|
LegoAssembly
=
None
self
.
layer
:
AggregationLayer
=
AggregationLayer
.
COMPONENT
self
.
properties
:
dict
=
{}
if
label
is
not
None
:
self
.
properties
[
'
label
'
]
=
label
self
.
properties
[
"
label
"
]
=
label
if
datasheet
is
not
None
:
self
.
properties
.
update
(
datasheet
)
for
prop
in
more_properties
:
...
...
@@ -32,14 +39,11 @@ class LegoComponent:
for
key
,
value
in
kwargs
.
items
():
self
.
properties
[
key
]
=
value
def
clone
(
self
,
new_label
:
Optional
[
str
]
=
None
)
->
LegoComponent
:
if
new_label
is
None
:
new_label
=
self
.
properties
[
'
label
'
]
new_label
=
self
.
properties
[
"
label
"
]
clone
=
LegoComponent
(
None
,
None
,
self
.
properties
)
clone
.
properties
[
'
label
'
]
=
new_label
clone
.
properties
[
"
label
"
]
=
new_label
return
clone
def
get_root_assembly
(
self
):
...
...
@@ -60,24 +64,25 @@ class LegoComponent:
def
__str__
(
self
):
return
self
.
__repr__
()
return
(
f
"
Item(id=
{
self
.
uuid
}
, item_number=
{
self
.
lego_id
}
,
"
f
"
mass=
{
self
.
mass
}
, delivery_time=
{
self
.
delivery_time
}
,
"
f
"
parent_id=
{
self
.
parent
}
)
"
)
def
__repr__
(
self
):
return
f
"
LegoComponent
{
self
.
properties
[
'
label
'
]
}
[
{
self
.
uuid
}
]
"
class
LegoAssembly
:
def
__init__
(
self
,
layer
:
AggregationLayer
,
label
:
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
.
parent
:
None
|
LegoAssembly
=
None
self
.
properties
:
dict
=
{}
self
.
layer
:
AggregationLayer
=
layer
if
label
is
not
None
:
self
.
properties
[
'
label
'
]
=
label
self
.
properties
[
"
label
"
]
=
label
for
prop
in
properties
:
if
isinstance
(
prop
,
dict
):
self
.
properties
.
update
(
prop
)
...
...
@@ -128,7 +133,9 @@ class LegoAssembly:
assembly
.
parent
=
self
self
.
assemblies
.
append
(
assembly
)
def
add
(
self
,
part
:
LegoAssembly
|
LegoComponent
|
List
[
LegoAssembly
|
LegoComponent
])
->
None
:
def
add
(
self
,
part
:
LegoAssembly
|
LegoComponent
|
List
[
LegoAssembly
|
LegoComponent
]
)
->
None
:
if
isinstance
(
part
,
LegoComponent
):
self
.
add_component
(
part
)
elif
isinstance
(
part
,
LegoAssembly
):
...
...
@@ -141,6 +148,7 @@ class LegoAssembly:
f
"
Argument should be of types
{
LegoAssembly
.
__name__
}
,
{
LegoComponent
.
__name__
}
or a list of them,
"
f
"
got
{
type
(
part
).
__name__
}
instead.
"
)
def
children
(
self
)
->
Dict
[
str
,
List
[
LegoComponent
]
|
List
[
LegoAssembly
]]:
return
{
"
components
"
:
self
.
components
,
"
assemblies
"
:
self
.
assemblies
}
...
...
@@ -197,6 +205,7 @@ class LegoAssembly:
clone
.
add_assembly
(
assembly
.
clone
())
return
clone
def
print_assembly_tree
(
root
,
level
=
0
,
is_last
=
False
):
if
not
isinstance
(
root
,
LegoAssembly
):
raise
TypeError
(
...
...
@@ -249,4 +258,4 @@ class KPIEncoder(json.JSONEncoder):
return
"
kpi-
"
+
str
(
o
)
if
isinstance
(
o
,
(
AggregationLayer
)):
return
"
kpi-
"
+
o
.
name
return
super
().
default
(
o
)
\ No newline at end of file
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