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
18706a6e
Commit
18706a6e
authored
3 years ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
FIX: parents were added multiple times to created records
parent
3052a97b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!53
Release 0.1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/newcrawler/converters.py
+5
-2
5 additions, 2 deletions
src/newcrawler/converters.py
src/newcrawler/utils.py
+40
-0
40 additions, 0 deletions
src/newcrawler/utils.py
with
45 additions
and
2 deletions
src/newcrawler/converters.py
+
5
−
2
View file @
18706a6e
...
...
@@ -26,6 +26,7 @@
import
os
import
re
import
caosdb
as
db
from
.utils
import
has_parent
from
.stores
import
GeneralStore
,
RecordStore
from
.structure_elements
import
(
StructureElement
,
Directory
,
File
,
TextElement
,
DictTextElement
,
DictListElement
)
...
...
@@ -183,9 +184,11 @@ class Converter(object):
if
"
parents
"
in
record
:
for
parent
in
record
[
"
parents
"
]:
c_record
.
add_parent
(
name
=
parent
)
if
not
has_parent
(
c_record
,
parent
):
c_record
.
add_parent
(
parent
)
else
:
c_record
.
add_parent
(
name
=
name
)
if
not
has_parent
(
c_record
,
name
):
c_record
.
add_parent
(
name
)
for
key
,
value
in
record
.
items
():
if
key
==
"
parents
"
:
...
...
This diff is collapsed.
Click to expand it.
src/newcrawler/utils.py
0 → 100644
+
40
−
0
View file @
18706a6e
#!/usr/bin/env python3
# encoding: utf-8
#
# ** header v3.0
# This file is a part of the CaosDB Project.
#
# Copyright (C) 2021 Henrik tom Wörden
# 2021 Alexander Schlemmer
#
# 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/>.
#
# ** end header
#
import
caosdb
as
db
# Some utility functions, e.g. for extending pylib.
def
has_parent
(
entity
:
db
.
Entity
,
name
:
str
):
"""
A simple check, whether a parent with the given name exists.
There is a similar, however more complex function in package caosdb.
"""
for
parent
in
entity
.
parents
:
if
parent
.
name
==
name
:
return
True
return
False
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