Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CaosDB Crawler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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 Crawler
Commits
2c57c5e6
Commit
2c57c5e6
authored
2 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
wip
parent
b60ece3a
No related branches found
No related tags found
2 merge requests
!91
Release 0.3
,
!67
MAINT: introduce an identifiable class
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caoscrawler/identifiable_adapters.py
+30
-40
30 additions, 40 deletions
src/caoscrawler/identifiable_adapters.py
with
30 additions
and
40 deletions
src/caoscrawler/identifiable_adapters.py
+
30
−
40
View file @
2c57c5e6
...
@@ -161,56 +161,46 @@ class IdentifiableAdapter(metaclass=ABCMeta):
...
@@ -161,56 +161,46 @@ class IdentifiableAdapter(metaclass=ABCMeta):
identifiable
identifiable
"""
"""
path
=
None
if
record
.
role
==
"
File
"
:
path
=
record
.
path
registered_identifiable
=
self
.
get_registered_identifiable
(
record
)
registered_identifiable
=
self
.
get_registered_identifiable
(
record
)
if
registered_identifiable
is
None
:
if
path
is
not
None
:
return
Identifiable
(
path
=
path
)
return
None
if
len
(
registered_identifiable
.
parents
)
!=
1
:
raise
RuntimeError
(
"
Multiple parents for identifiables
"
"
not supported.
"
)
property_name_list_A
=
[]
property_name_list_A
=
[]
property_name_list_B
=
[]
property_name_list_B
=
[]
identifiable_props
=
{}
identifiable_props
=
{}
# fill the values:
if
registered_identifiable
is
not
None
:
for
prop
in
registered_identifiable
.
properties
:
# fill the values:
if
prop
.
name
==
"
name
"
:
for
prop
in
registered_identifiable
.
properties
:
# The name can be an identifiable, but it isn't a property
if
prop
.
name
==
"
name
"
:
continue
# The name can be an identifiable, but it isn't a property
# problem: what happens with multi properties?
continue
# case A: in the registered identifiable
# problem: what happens with multi properties?
# case B: in the identifiable
# case A: in the registered identifiable
# case B: in the identifiable
record_prop
=
record
.
get_property
(
prop
.
name
)
if
record_prop
is
None
:
record_prop
=
record
.
get_property
(
prop
.
name
)
# TODO: how to handle missing values in identifiables
if
record_prop
is
None
:
# raise an exception?
# TODO: how to handle missing values in identifiables
raise
NotImplementedError
(
# raise an exception?
f
"
The following record is missing an identifying property:
"
raise
NotImplementedError
(
f
"
RECORD
\n
{
record
}
\n
Identifying PROPERTY
\n
{
prop
.
name
}
"
f
"
The following record is missing an identifying property:
"
)
f
"
RECORD
\n
{
record
}
\n
Identifying PROPERTY
\n
{
prop
.
name
}
"
identifiable_props
[
record_prop
.
name
]
=
record_prop
.
value
)
property_name_list_A
.
append
(
prop
.
name
)
identifiable_props
[
record_prop
.
name
]
=
record_prop
.
value
property_name_list_A
.
append
(
prop
.
name
)
# check for multi properties in the record:
for
prop
in
property_name_list_A
:
# check for multi properties in the record:
property_name_list_B
.
append
(
prop
)
for
prop
in
property_name_list_A
:
if
(
len
(
set
(
property_name_list_B
))
!=
len
(
property_name_list_B
)
or
len
(
property_name_list_B
.
append
(
prop
)
set
(
property_name_list_A
))
!=
len
(
property_name_list_A
)):
if
(
len
(
set
(
property_name_list_B
))
!=
len
(
property_name_list_B
)
or
len
(
raise
RuntimeError
(
set
(
property_name_list_A
))
!=
len
(
property_name_list_A
)):
"
Multi properties used in identifiables could cause unpredictable results and are
"
raise
RuntimeError
(
"
not allowed. You might want to consider a Property with a list as value.
"
)
"
Multi properties used in identifiables could cause unpredictable results and are
"
"
not allowed. You might want to consider a Property with a list as value.
"
)
return
Identifiable
(
record_type
=
registered_identifiable
.
parents
[
0
].
name
,
return
Identifiable
(
record_type
=
registered_identifiable
.
parents
[
0
].
name
,
name
=
record
.
name
,
name
=
record
.
name
,
properties
=
identifiable_props
,
properties
=
identifiable_props
,
path
=
path
path
=
record
.
path
)
)
@abstractmethod
@abstractmethod
...
...
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