Skip to content
Snippets Groups Projects
Commit 30f45688 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

more parsing of headers

parent 5f904500
No related branches found
No related tags found
No related merge requests found
......@@ -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:
......
......@@ -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")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment