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

add Directory class

parent 21b23139
Branches
No related tags found
2 merge requests!86Draft: ENH: file system: core,!58F filesystem
Pipeline #18101 failed
......@@ -1684,6 +1684,37 @@ class Record(Entity):
return Entity.to_xml(self, xml, add_properties=ALL)
class Directory(Record):
"""This class represents CaosDB's directory entities."""
def __init__(self, name=None, id=None, description=None, path=None):
Record.__init__(self, id=id, name=name, description=description)
self.role = "Directory"
self.datatype = None
# location in the fileserver
self.path = path
def to_xml(self, xml=None, add_properties=ALL, local_serialization=False):
"""Convert this file to an xml element.
@return: xml element
"""
if xml is None:
xml = etree.Element("Directory")
return Entity.to_xml(self, xml=xml, add_properties=add_properties,
local_serialization=local_serialization)
def add_property(self, property=None, id=None, name=None, description=None, datatype=None,
value=None, unit=None, importance=FIX, inheritance=FIX): # @ReservedAssignment
return super().add_property(
property=property, id=id, name=name, description=description, datatype=datatype,
value=value, unit=unit, importance=importance, inheritance=inheritance)
class File(Record):
"""This class represents CaosDB's file entities.
......@@ -2931,6 +2962,11 @@ class Container(list):
sync_remote_entities = []
for remote_entity in remote_container:
# legacy API - remove new directories.
if unique and remote_entity.role is not None and remote_entity.role.lower() == "directory":
continue;
if not (remote_entity in used_remote_entities):
sync_remote_entities.append(remote_entity)
......@@ -3367,10 +3403,10 @@ class Container(list):
def insert(self, strict=False, raise_exception_on_error=True,
unique=True, sync=True, flags=None):
"""Insert this file entity into CaosDB. A successful insertion will
generate a new persistent ID for this entity. This entity can be
identified, retrieved, updated, and deleted via this ID until it has
been deleted.
"""Insert these entities into CaosDB. A successful insertion will
generate a persistent ID for the new entities. These entities can be
identified, retrieved, updated, and deleted via their ID until they
have been deleted.
If the insertion fails, a CaosDBException will be raised. The server will have returned at
least one error-message describing the reason why it failed in that case (call
......@@ -4215,6 +4251,7 @@ def _parse_single_xml_element(elem):
'recordtype': RecordType,
'property': Property,
'file': File,
'directory': Directory,
'parent': Parent,
'entity': Entity}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment