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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Crawler
Commits
c8242836
Verified
Commit
c8242836
authored
May 29, 2024
by
Daniel Hornung
Browse files
Options
Downloads
Plain Diff
Merge branch 'f-fix-93' into f-sav-converter
parents
61df7fe9
b3f14469
No related branches found
No related tags found
2 merge requests
!178
FIX: #96 Better error output for crawl.py script.
,
!171
sav/spss converter
Pipeline
#51520
passed with warnings
May 29, 2024
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caoscrawler/converters.py
+6
-2
6 additions, 2 deletions
src/caoscrawler/converters.py
unittests/test_issues.py
+26
-2
26 additions, 2 deletions
unittests/test_issues.py
with
32 additions
and
4 deletions
src/caoscrawler/converters.py
+
6
−
2
View file @
c8242836
...
...
@@ -52,12 +52,16 @@ from .utils import has_parent
# by the converters:
SPECIAL_PROPERTIES
=
(
"
description
"
,
"
name
"
,
"
id
"
,
"
path
"
,
"
file
"
,
"
checksum
"
,
"
size
"
)
SINGLE_VAR_RE
=
re
.
compile
(
r
"
^\$(\{)?(?P<varname>\w+)(\})?$
"
)
ID_PATTERN
=
r
"
\D[.\w]*
"
SINGLE_VAR_RE
=
re
.
compile
(
r
"
^\$(\{)?(?P<varname>
"
+
ID_PATTERN
+
r
"
)(\})?$
"
)
logger
=
logging
.
getLogger
(
__name__
)
class
CrawlerTemplate
(
Template
):
braceidpattern
=
r
"
(?a:[_a-z][_\.a-z0-9]*)
"
# This also adds a dot to the default pattern.
# See: https://docs.python.org/3/library/string.html#template-strings
# Default flags is re.IGNORECASE
braceidpattern
=
ID_PATTERN
def
_only_max
(
children_with_keys
):
...
...
This diff is collapsed.
Click to expand it.
unittests/test_issues.py
+
26
−
2
View file @
c8242836
...
...
@@ -22,7 +22,7 @@
from
pytest
import
mark
from
caoscrawler.converters
import
replace_variables
from
caoscrawler.converters
import
replace_variables
,
CrawlerTemplate
from
caoscrawler.crawl
import
Crawler
from
caoscrawler.structure_elements
import
DictElement
from
caoscrawler.stores
import
GeneralStore
...
...
@@ -115,11 +115,35 @@ def test_issue_93():
cfood.yaml does not allow umlaut in $expression
"""
values
=
GeneralStore
()
expressions
=
[
"
1
"
,
"
foo
"
,
"
foo.bär
"
,
"
_1
"
,
"
Ä
"
,
"
ųøîµ
"
,
]
for
exp
in
expressions
:
values
[
exp
]
=
f
"
This is
{
exp
}
"
# ## Test preliminary check
# With braces
for
exp
in
expressions
:
assert
replace_variables
(
f
"
${{
{
exp
}
}}
"
,
values
)
==
f
"
This is
{
exp
}
"
# Without braces
for
exp
in
expressions
:
assert
replace_variables
(
f
"
$
{
exp
}
"
,
values
)
==
f
"
This is
{
exp
}
"
# ## Test actual replacement
for
exp
in
expressions
:
# as-is
propvalue
=
f
"
${{
{
exp
}
}}
"
propvalue_template
=
CrawlerTemplate
(
propvalue
)
# from IPython import embed
# embed()
assert
propvalue_template
.
safe_substitute
(
**
values
.
get_storage
())
==
f
"
This is
{
exp
}
"
# String embedded into context
propvalue
=
f
"
some text before >> ${{
{
exp
}
}} << some text after
"
print
(
propvalue
)
propvalue_template
=
CrawlerTemplate
(
propvalue
)
assert
(
propvalue_template
.
safe_substitute
(
**
values
.
get_storage
())
==
f
"
some text before >> This is
{
exp
}
<< some text after
"
)
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