diff --git a/src/caosadvancedtools/cfood.py b/src/caosadvancedtools/cfood.py index eca51a1689b57b2b75effbb4b357edc0e99e351e..94fd3892ab684fbc0de6e8747f86e057e44d7779 100644 --- a/src/caosadvancedtools/cfood.py +++ b/src/caosadvancedtools/cfood.py @@ -31,15 +31,15 @@ from datetime import datetime import caosdb as db from caosdb.exceptions import TransactionError -from something import get_entity +#from something import get_entity class AbstractCFood(object): def __init__(self, pattern): self.pattern = re.compile(pattern) - def treat_match(self, filename, match): - entities = self.create_identifiables(filename, match) + def treat_match(self, crawled_file, match): + entities = self.create_identifiables(crawled_file, match) for key, ent in entities.items(): existing = AbstractCFood.find_existing(ent) @@ -53,12 +53,12 @@ class AbstractCFood(object): print(key, "exists") entities[key] = existing - self.update_identifiables(entities, filename, match) + self.update_identifiables(entities, crawled_file, match) - def create_identifiables(self, filename, match): + def create_identifiables(self, crawled_file, match): raise NotImplementedError() - def update_identifiables(self, entities, filename, match): + def update_identifiables(self, entities, crawled_file, match): raise NotImplementedError() @staticmethod @@ -92,22 +92,6 @@ class AbstractCFood(object): return r -class ExampleCFood(AbstractCFood): - def create_identifiables(self, filename, match): - entities = {} - entities["exp"] = db.Record() - #import IPython - # IPython.embed() - entities["exp"].add_parent(name="Experiment") - entities["exp"].add_property(name="species", value=match.group) - - return entities - - def update_identifiables(self, entities, filename, match): - entities["exp"].add_property(name="date", - value=datetime.today().isoformat()) - db.Container().extend(entities.values).update() - def get_parser(): parser = argparse.ArgumentParser(description=__doc__, diff --git a/src/caosadvancedtools/crawler.py b/src/caosadvancedtools/crawler.py index 24374607d5788bd224e267db8caaae28e8f5238b..51f07367ae0dbebc388173e1ce1db96e0a0ec921 100644 --- a/src/caosadvancedtools/crawler.py +++ b/src/caosadvancedtools/crawler.py @@ -1,5 +1,27 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- +#!/usr/bin/env python +# encoding: utf-8 +# +# ** header v3.0 +# This file is a part of the CaosDB Project. +# +# Copyright (C) 2018 Research Group Biomedical Physics, +# Max-Planck-Institute for Dynamics and Self-Organization Göttingen +# +# 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 +# """does something""" import argparse @@ -7,8 +29,6 @@ from argparse import RawTextHelpFormatter import caosdb as db -from cfood import CFood - class Crawler(object): def __init__(self, food): @@ -31,17 +51,3 @@ class Crawler(object): cfood.treat_match(crawled_file.path, match) -def get_parser(): - parser = argparse.ArgumentParser(description=__doc__, - formatter_class=RawTextHelpFormatter) - - return parser - - -if __name__ == "__main__": - parser = get_parser() - args = parser.parse_args() - - f = CFood(pattern="(.*)to(.*)") - c = Crawler(food=[f]) - c.crawl(["path/to/file"]) diff --git a/src/caosadvancedtools/loadFiles.py b/src/caosadvancedtools/loadFiles.py index 953cfc458eba42eeabd1df1dfeaa6c828afc0d0b..9ebf8b9f27fbe7d3980af7941de733624f96b17c 100755 --- a/src/caosadvancedtools/loadFiles.py +++ b/src/caosadvancedtools/loadFiles.py @@ -26,6 +26,7 @@ import math import sys from argparse import ArgumentParser +import argparse import caosdb as db