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
85bc5783
Commit
85bc5783
authored
5 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
DEV: introduced CMeal, an addition for CFood that allows to collect similar files in one CFood
parent
84b62645
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caosadvancedtools/cfood.py
+47
-0
47 additions, 0 deletions
src/caosadvancedtools/cfood.py
with
47 additions
and
0 deletions
src/caosadvancedtools/cfood.py
+
47
−
0
View file @
85bc5783
...
@@ -91,6 +91,25 @@ class AbstractCFood(object):
...
@@ -91,6 +91,25 @@ class AbstractCFood(object):
"""
"""
raise
NotImplementedError
()
raise
NotImplementedError
()
@classmethod
def
cook
(
cls
,
crawled_file
):
"""
possibly checks for existing CFoods whether the match should be
added or whether a new CFood instance needs to be returned
This function should typically be used to create CFoods in order to
prevent the creation of unnecessary instances.
This standard implementation does not do a check but may be overwritten
by subclasses.
Retruns
-------------
CFood: if a new instance was created
None: otherwise
"""
return
cls
()
@classmethod
@classmethod
def
match
(
cls
,
string
):
def
match
(
cls
,
string
):
"""
Matches the regular expression of this class against file names
"""
Matches the regular expression of this class against file names
...
@@ -337,3 +356,31 @@ def get_ids_for_entities_with_names(entities):
...
@@ -337,3 +356,31 @@ def get_ids_for_entities_with_names(entities):
for
parent
in
ent
.
get_parents
():
for
parent
in
ent
.
get_parents
():
insert_id_based_on_name
(
parent
)
insert_id_based_on_name
(
parent
)
insert_id_based_on_name
(
ent
)
insert_id_based_on_name
(
ent
)
class
CMeal
(
object
):
existing_instances
=
[]
matching_groups
=
[]
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
existing_instances
.
append
(
self
)
self
.
crawled_files
=
[]
def
add
(
self
,
crawled_file
):
self
.
crawled_files
.
append
(
crawled_file
)
@classmethod
def
get_suitable_cfood
(
cls
,
match
):
for
cfood
in
cls
.
existing_instances
:
suitable
=
True
for
group
in
cls
.
matching_groups
:
if
(
group
not
in
match
or
group
not
in
cfood
.
match
or
match
.
group
(
group
)
==
cfood
.
match
.
group
(
group
)):
suitable
=
False
if
suitable
:
return
cfood
return
None
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