Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-advanced-user-tools
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-advanced-user-tools
Commits
30f45688
Commit
30f45688
authored
5 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
more parsing of headers
parent
5f904500
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caosadvancedtools/cfood.py
+2
-12
2 additions, 12 deletions
src/caosadvancedtools/cfood.py
src/caosadvancedtools/read_md_header.py
+33
-0
33 additions, 0 deletions
src/caosadvancedtools/read_md_header.py
with
35 additions
and
12 deletions
src/caosadvancedtools/cfood.py
+
2
−
12
View file @
30f45688
...
...
@@ -56,10 +56,11 @@ class AbstractCFood(object):
self
.
use_cache
=
use_cache
def
treat_match
(
self
,
crawled_file
,
match
):
print
(
crawled_file
)
entities
=
self
.
create_identifiables
(
crawled_file
,
match
)
for
key
,
identifiable
in
entities
.
items
():
print
(
identifiable
)
if
identifiable
is
None
:
print
(
"
THIS IS STRANGE
"
)
...
...
@@ -70,19 +71,11 @@ class AbstractCFood(object):
if
self
.
use_cache
:
identifiable_cache
=
Cache
()
identifier
=
Cache
.
hash_entity
(
identifiable
)
print
(
"
look for
'
{}
'
in Cache
"
.
format
(
identifiable
.
get_parents
()[
0
]))
print
(
identifiable
)
cached_id
=
identifiable_cache
.
check_existing
(
identifier
)
if
cached_id
is
not
None
:
print
(
cached_id
)
print
(
"
found Entity
'
{}
'
in Cache
"
.
format
(
identifiable
.
get_parents
()[
0
]))
existing
=
db
.
execute_query
(
"
FIND {}
"
.
format
(
cached_id
),
unique
=
True
)
else
:
print
(
"
did not found Entity
'
{}
'
in Cache
"
.
format
(
identifiable
.
get_parents
()[
0
]))
# Nothing in cache or cache not used. Check in CaosDB
...
...
@@ -92,12 +85,9 @@ class AbstractCFood(object):
# No record matching the identifiable was found. Insert the record
if
existing
is
None
:
print
(
key
,
"
does not exist
"
)
identifiable
.
insert
()
print
(
key
,
"
inserted
"
)
entities
[
key
]
=
identifiable
else
:
print
(
key
,
"
exists
"
)
entities
[
key
]
=
existing
if
self
.
use_cache
and
cached_id
is
None
:
...
...
This diff is collapsed.
Click to expand it.
src/caosadvancedtools/read_md_header.py
+
33
−
0
View file @
30f45688
...
...
@@ -28,6 +28,7 @@
import
os
import
re
import
caosdb
as
db
import
yaml
TEMPLATEHEADER
=
"""
...
...
@@ -193,3 +194,35 @@ def _add_header(filename):
with
open
(
filename
,
"
w
"
)
as
f
:
f
.
write
(
localheader
)
f
.
writelines
(
textlines
)
def
parse_responsibles
(
header
):
people
=
[]
for
person
in
header
[
"
responsible
"
]:
firstname
=
person
.
split
(
"
"
)[
0
]
lastname
=
person
.
split
(
"
"
)[
1
]
p
=
db
.
Record
()
p
.
add_parent
(
"
Person
"
)
p
.
add_property
(
"
lastname
"
,
lastname
)
p
.
add_property
(
"
firstname
"
,
firstname
)
people
.
append
(
p
)
return
people
def
reference_data_files
(
entity
,
header
):
for
glob
in
header
[
"
data
"
]:
for
dfile
in
find_file_for_fileglob
(
glob
):
entity
.
add_property
(
"
data
"
,
dfile
)
def
find_file_for_fileglob
(
glob
):
# TODO this probalby needs to be extended for different kinds of glob
res
=
db
.
execute_query
(
"
FIND file which is stored at {}
"
.
format
(
glob
))
def
find_records_referencing_files
(
glob
):
# is it possible to reference the "data records"? anything might
# reference this file
db
.
execute_query
(
"
FIND Record which references file which is stored
at
"
)
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