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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-pylib
Commits
178a4832
Verified
Commit
178a4832
authored
Jan 14, 2022
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
add Directory class
parent
21b23139
Branches
Branches containing commit
No related tags found
2 merge requests
!86
Draft: ENH: file system: core
,
!58
F filesystem
Pipeline
#18101
failed
Jan 14, 2022
Stage: code_style
Stage: linting
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caosdb/common/models.py
+41
-4
41 additions, 4 deletions
src/caosdb/common/models.py
with
41 additions
and
4 deletions
src/caosdb/common/models.py
+
41
−
4
View file @
178a4832
...
...
@@ -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 th
is fil
e entit
y
into CaosDB. A successful insertion will
generate a
new
persistent ID for th
is
entit
y
. Th
is
entit
y
can be
identified, retrieved, updated, and deleted via th
is
ID until
it has
been deleted.
"""
Insert th
es
e entit
ies
into CaosDB. A successful insertion will
generate a persistent ID for th
e new
entit
ies
. Th
ese
entit
ies
can be
identified, retrieved, updated, and deleted via th
eir
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
}
...
...
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