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
cdd33a76
Commit
cdd33a76
authored
1 year ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
up
parent
e7fe83ab
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!178
FIX: #96 Better error output for crawl.py script.
,
!167
Sync Graph
Pipeline
#50071
failed
1 year ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caoscrawler/sync_node.py
+99
-0
99 additions, 0 deletions
src/caoscrawler/sync_node.py
with
99 additions
and
0 deletions
src/caoscrawler/sync_node.py
0 → 100644
+
99
−
0
View file @
cdd33a76
#!/usr/bin/env python3
# encoding: utf-8
#
# This file is a part of the LinkAhead Project.
#
# Copyright (C) 2024 Henrik tom Wörden
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
from
__future__
import
annotations
from
typing
import
Any
,
Dict
,
List
,
Optional
,
Union
from
uuid
import
uuid4
as
uuid
import
linkahead
as
db
class
SyncNode
():
"""
represents the information related to an Entity as it shall be created in LinkAhead
The following information is taken from db.Entity object during initialization or when the
object is updated using `update(entity)`:
- id
- role
- parents
- path
- name
- description
- properties
Typically, this class is used in the following way:
1. A SyncNode is initialized with a db.Entity object
2. The SyncNode object is possibly updated one or more times with further db.Entity objects
3. A db.Entity object is created (`export_entity`) that contains the combined information of
the previous db.Entity objects.
"""
def
__init__
(
self
,
entity
:
db
.
Entity
,
registered_identifiable
:
Optional
[
db
.
RecordType
]
=
None
)
->
None
:
self
.
id
=
entity
.
id
self
.
role
=
entity
.
role
self
.
parents
=
entity
.
parents
self
.
path
=
entity
.
path
self
.
name
=
entity
.
name
self
.
description
=
entity
.
description
self
.
properties
=
list
(
entity
.
properties
)
self
.
uuid
=
uuid
()
self
.
identifiable
=
None
self
.
registered_identifiable
=
registered_identifiable
def
update
(
self
,
other
:
SyncNode
)
->
None
:
if
other
.
identifiable
is
not
None
and
self
.
identifiable
is
not
None
:
assert
(
other
.
identifiable
.
get_representation
()
==
self
.
identifiable
.
get_representation
())
for
attr
in
[
"
id
"
,
"
path
"
,
"
role
"
,
"
path
"
,
"
name
"
,
"
description
"
]:
if
other
.
__getattribute__
(
attr
)
is
not
None
:
if
self
.
__getattribute__
(
attr
)
is
None
:
self
.
__setattr__
(
attr
,
other
.
__getattribute__
(
attr
))
else
:
assert
self
.
__getattribute__
(
attr
)
==
other
.
__getattribute__
(
attr
)
for
p
in
other
.
parents
:
if
p
not
in
self
.
parents
:
self
.
parents
.
append
(
p
)
for
p
in
other
.
properties
:
if
p
not
in
self
.
properties
:
self
.
properties
.
append
(
p
)
def
export_entity
(
self
)
->
db
.
Entity
:
ent
=
None
if
self
.
role
==
"
Record
"
:
ent
=
db
.
Record
()
elif
self
.
role
==
"
File
"
:
ent
=
db
.
File
()
else
:
raise
RuntimeError
(
"
Invalid role
"
)
for
attr
in
[
"
id
"
,
"
path
"
,
"
role
"
,
"
path
"
,
"
name
"
,
"
description
"
]:
ent
.
__setattr__
(
attr
,
self
.
__getattribute__
(
attr
))
for
p
in
self
.
parents
:
ent
.
add_parent
(
p
)
for
p
in
self
.
properties
:
if
ent
.
get_property
(
p
)
is
not
None
:
if
ent
.
get_property
(
p
).
value
!=
p
.
value
:
raise
Exception
()
else
:
ent
.
add_property
(
p
)
return
ent
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