Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CaosDB Crawler
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 Crawler
Commits
45926a37
Commit
45926a37
authored
1 year ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
ENH: working implementation of transformer functions
parent
1d1f3b63
No related branches found
No related tags found
2 merge requests
!160
STY: styling
,
!126
Transformers
Pipeline
#39513
passed with warnings
1 year ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caoscrawler/transformer_functions.py
+8
-1
8 additions, 1 deletion
src/caoscrawler/transformer_functions.py
unittests/test_transformers.py
+6
-2
6 additions, 2 deletions
unittests/test_transformers.py
with
14 additions
and
3 deletions
src/caoscrawler/transformer_functions.py
+
8
−
1
View file @
45926a37
...
@@ -4,5 +4,12 @@
...
@@ -4,5 +4,12 @@
from
typing
import
Any
from
typing
import
Any
import
re
def
ifelse
(
in_value
:
Any
,
in_parameters
:
dict
):
def
ifelse
(
in_value
:
Any
,
in_parameters
:
dict
):
raise
NotImplementedError
()
if
"
match
"
not
in
in_parameters
or
"
then
"
not
in
in_parameters
:
raise
RuntimeError
(
"
Mandatory parameters missing.
"
)
if
re
.
match
(
in_parameters
[
"
match
"
],
in_value
)
is
not
None
:
return
in_parameters
[
"
then
"
]
return
in_value
This diff is collapsed.
Click to expand it.
unittests/test_transformers.py
+
6
−
2
View file @
45926a37
...
@@ -59,14 +59,18 @@ def test_simple_transformer():
...
@@ -59,14 +59,18 @@ def test_simple_transformer():
records
=
scan_directory
(
UNITTESTDIR
/
"
test_directories
"
/
"
test_transformers
"
,
records
=
scan_directory
(
UNITTESTDIR
/
"
test_directories
"
/
"
test_transformers
"
,
UNITTESTDIR
/
"
test_directories
"
/
"
test_transformers
"
/
UNITTESTDIR
/
"
test_directories
"
/
"
test_transformers
"
/
"
cfood.yml
"
)
"
cfood.yml
"
)
breakpoint
()
for
r
in
records
:
for
r
in
records
:
assert
r
.
get_property
(
"
Day
"
)
is
not
None
assert
r
.
get_property
(
"
Day
"
)
is
not
None
assert
r
.
get_property
(
"
DayShort
"
)
is
not
None
assert
r
.
get_property
(
"
DayShort
"
)
is
not
None
assert
r
.
get_property
(
"
DayShort
"
).
value
!=
"
$day_short
"
assert
r
.
get_property
(
"
DayShort
"
).
value
!=
"
$day_short
"
if
r
.
get_property
(
"
DayShort
"
).
value
==
"
Unk
"
:
if
r
.
get_property
(
"
DayShort
"
).
value
==
"
Unk
"
:
# This unkown folder should not lead to a replacement
# This unkown folder should not lead to a replacement
assert
r
.
get_property
(
"
Day
"
).
value
==
"
$day_long
"
assert
r
.
get_property
(
"
Day
"
).
value
==
"
Unk
"
elif
r
.
get_property
(
"
DayShort
"
).
value
==
"
Mon
"
:
assert
r
.
get_property
(
"
Day
"
).
value
==
"
Monday
"
elif
r
.
get_property
(
"
DayShort
"
).
value
==
"
Tue
"
:
assert
r
.
get_property
(
"
Day
"
).
value
==
"
Tuesday
"
else
:
else
:
assert
r
.
get_property
(
"
Day
"
).
value
!=
"
$day_long
"
assert
r
.
get_property
(
"
Day
"
).
value
!=
"
$day_long
"
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