Skip to content
Snippets Groups Projects
Verified Commit a66f9fe0 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

DOC: update CHANGELOG and add source docs

parent f8861d5e
Branches
Tags
1 merge request!3F fsm
...@@ -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 ###
......
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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment