Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
PyI40AAS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
Lehrstuhl für Informations- und Automatisierungssysteme
PyI40AAS
Merge requests
!29
Feature/updatable classes
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Feature/updatable classes
feature/updatable_classes
into
master
Overview
0
Commits
7
Pipelines
5
Changes
2
Merged
Sebastian Heppner
requested to merge
feature/updatable_classes
into
master
5 years ago
Overview
0
Commits
7
Pipelines
5
Changes
2
Expand
0
0
Merge request reports
Compare
master
version 1
7832ca8b
5 years ago
master (base)
and
latest version
latest version
9eadf4c2
7 commits,
5 years ago
version 1
7832ca8b
15 commits,
5 years ago
2 files
+
84
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
aas/model/base.py
+
64
−
0
Options
@@ -463,6 +463,41 @@ class Referable(metaclass=abc.ABCMeta):
raise
ValueError
(
"
The id_short must start with a letter
"
)
self
.
_id_short
=
id_short
def
update
(
self
,
timeout
:
float
=
0
)
->
None
:
"""
Update the local Referable object from the underlying backend.
If the object does not belong to a backend, i.e. it is a simple in-memory object, this function does nothing.
:param timeout: Only update the object, if it has not been updated within the last `timeout` seconds.
"""
pass
def
update_from
(
self
,
other
:
"
Referable
"
):
"""
Internal function to updates the object
'
s attributes from another object of a similar type.
This function should not be used directly. It is typically used by backend implementations (database adapters,
protocol clients, etc.) to update the object
'
s data, after `update()` has been called.
:param other: The object to update from
"""
for
name
,
var
in
vars
(
other
).
items
():
if
name
==
"
parent
"
:
# do not update the parent
continue
if
isinstance
(
var
,
NamespaceSet
):
# update the elements of the NameSpaceSet
vars
(
self
)[
name
].
update_nss_from
(
var
)
vars
(
self
)[
name
]
=
var
# that variable is not a NameSpaceSet, so it isn't Referable
def
commit
(
self
)
->
None
:
"""
Transfer local changes on this object to the underlying backend.
If the object does not belong to a backend, i.e. it is a simple in-memory object, this function does nothing.
"""
pass
id_short
=
property
(
_get_id_short
,
_set_id_short
)
@@ -965,6 +1000,35 @@ class NamespaceSet(MutableSet[_RT], Generic[_RT]):
"""
return
self
.
_backend
.
get
(
key
,
default
)
def
update_nss_from
(
self
,
other
:
"
NamespaceSet
"
):
"""
Update a NamespaceSet from a given NamespaceSet.
WARNING: By updating, the
"
other
"
NamespaceSet gets destroyed.
:param other: The NamespaceSet to update from
"""
referables_to_add
:
List
[
Referable
]
=
[]
# objects from the other nss to add to self
referables_to_remove
:
List
[
Referable
]
=
[]
# objects to remove from self
for
other_referable
in
other
:
try
:
referable
=
self
.
_backend
[
other_referable
.
id_short
]
if
type
(
referable
)
is
type
(
other_referable
):
# referable is the same as other referable
referable
.
update_from
(
other_referable
)
except
KeyError
:
# other referable is not in NamespaceSet
referables_to_add
.
append
(
other_referable
)
for
id_short
,
referable
in
self
.
_backend
.
items
():
if
not
other
.
get
(
id_short
):
# referable does not exist in the other NamespaceSet
referables_to_remove
.
append
(
referable
)
for
referable_to_add
in
referables_to_add
:
other
.
remove
(
referable_to_add
)
self
.
add
(
referable_to_add
)
# type: ignore
for
referable_to_remove
in
referables_to_remove
:
self
.
remove
(
referable_to_remove
)
# type: ignore
class
OrderedNamespaceSet
(
NamespaceSet
[
_RT
],
MutableSequence
[
_RT
],
Generic
[
_RT
]):
"""
Loading