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
ec13ec8f
Commit
ec13ec8f
authored
6 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
update
parent
049ed856
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/caosadvancedtools/cfood.py
+6
-22
6 additions, 22 deletions
src/caosadvancedtools/cfood.py
src/caosadvancedtools/crawler.py
+24
-18
24 additions, 18 deletions
src/caosadvancedtools/crawler.py
src/caosadvancedtools/loadFiles.py
+1
-0
1 addition, 0 deletions
src/caosadvancedtools/loadFiles.py
with
31 additions
and
40 deletions
src/caosadvancedtools/cfood.py
+
6
−
22
View file @
ec13ec8f
...
...
@@ -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
,
filenam
e
,
match
):
entities
=
self
.
create_identifiables
(
filenam
e
,
match
)
def
treat_match
(
self
,
crawled_fil
e
,
match
):
entities
=
self
.
create_identifiables
(
crawled_fil
e
,
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
,
filenam
e
,
match
)
self
.
update_identifiables
(
entities
,
crawled_fil
e
,
match
)
def
create_identifiables
(
self
,
filenam
e
,
match
):
def
create_identifiables
(
self
,
crawled_fil
e
,
match
):
raise
NotImplementedError
()
def
update_identifiables
(
self
,
entities
,
filenam
e
,
match
):
def
update_identifiables
(
self
,
entities
,
crawled_fil
e
,
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__
,
...
...
This diff is collapsed.
Click to expand it.
src/caosadvancedtools/crawler.py
+
24
−
18
View file @
ec13ec8f
#!/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
"
])
This diff is collapsed.
Click to expand it.
src/caosadvancedtools/loadFiles.py
+
1
−
0
View file @
ec13ec8f
...
...
@@ -26,6 +26,7 @@
import
math
import
sys
from
argparse
import
ArgumentParser
import
argparse
import
caosdb
as
db
...
...
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