Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-pylib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
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
Code review analytics
Issue 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
caosdb
Software
caosdb-pylib
Commits
a66f9fe0
Verified
Commit
a66f9fe0
authored
4 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
DOC: update CHANGELOG and add source docs
parent
f8861d5e
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!3
F fsm
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+2
-0
2 additions, 0 deletions
CHANGELOG.md
src/caosdb/common/state.py
+30
-0
30 additions, 0 deletions
src/caosdb/common/state.py
with
32 additions
and
0 deletions
CHANGELOG.md
+
2
−
0
View file @
a66f9fe0
...
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
...
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ###
### Added ###
*
Entity State support (experimental). See the
`caosdb.State`
class for more
information.
*
Versioning support (experimental).
*
Versioning support (experimental).
### Changed ###
### Changed ###
...
...
This diff is collapsed.
Click to expand it.
src/caosdb/common/state.py
+
30
−
0
View file @
a66f9fe0
from
lxml
import
etree
from
lxml
import
etree
class
State
:
class
State
:
"""
State
Represents the state of an entity and take care of the serialization and
deserialization of xml for the entity state.
An entity state is always a State of a StateModel.
Properties
----------
name : str
Name of the State
model : str
Name of the StateModel
"""
def
__init__
(
self
,
model
,
name
):
def
__init__
(
self
,
model
,
name
):
self
.
name
=
name
self
.
name
=
name
...
@@ -19,6 +33,12 @@ class State:
...
@@ -19,6 +33,12 @@ class State:
return
f
"
State(
'
{
self
.
model
}
'
,
'
{
self
.
name
}
'
)
"
return
f
"
State(
'
{
self
.
model
}
'
,
'
{
self
.
name
}
'
)
"
def
to_xml
(
self
):
def
to_xml
(
self
):
"""
Serialize this State to xml.
Returns
-------
xml : etree.Element
"""
xml
=
etree
.
Element
(
"
State
"
)
xml
=
etree
.
Element
(
"
State
"
)
if
self
.
name
is
not
None
:
if
self
.
name
is
not
None
:
xml
.
set
(
"
name
"
,
self
.
name
)
xml
.
set
(
"
name
"
,
self
.
name
)
...
@@ -28,6 +48,16 @@ class State:
...
@@ -28,6 +48,16 @@ class State:
@staticmethod
@staticmethod
def
from_xml
(
xml
):
def
from_xml
(
xml
):
"""
Create a new State instance from an xml Element.
Parameters
----------
xml : etree.Element
Returns
-------
state : State
"""
name
=
xml
.
get
(
"
name
"
)
name
=
xml
.
get
(
"
name
"
)
model
=
xml
.
get
(
"
model
"
)
model
=
xml
.
get
(
"
model
"
)
return
State
(
name
=
name
,
model
=
model
)
return
State
(
name
=
name
,
model
=
model
)
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