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
43a23d05
Verified
Commit
43a23d05
authored
11 months ago
by
Daniel Hornung
Browse files
Options
Downloads
Patches
Plain Diff
ENH: SPSS to cfood has macro for reference properties now.
parent
c6b21904
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
#51344
passed with warnings
11 months 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/conv_impl/spss.py
+46
-15
46 additions, 15 deletions
src/caoscrawler/conv_impl/spss.py
unittests/test_issues.py
+0
-1
0 additions, 1 deletion
unittests/test_issues.py
with
46 additions
and
16 deletions
src/caoscrawler/conv_impl/spss.py
+
46
−
15
View file @
43a23d05
...
@@ -75,31 +75,49 @@ metadata:
...
@@ -75,31 +75,49 @@ metadata:
name: ColumnValue
name: ColumnValue
params:
params:
name: null
name: null
belongsto: BaseElement
type: TextElement
type: TextElement
parent: MyParent
definition:
definition:
${name}:
${name}:
type: ${type}
type: ${type}
match_name: ${name}
match_name:
^
${name}
$$
match_value: (?P<val>.*)
match_value: (?P<val>.*)
records:
records:
${
parent
}:
${
belongsto
}:
${name}: $$val
${name}: $$val
- !defmacro
# column value -> reference property
name: ColumnValueReference
params:
name: null
reftype: null # RecordType of the reference
belongsto: BaseElement
type: TextElement # References are always text, right?
definition:
${name}:
type: ${type}
match_name: ^${name}$$
match_value: (?P<val>.*)
records:
${reftype}:
name: $$val
${belongsto}:
${name}: $$${reftype}
- !defmacro
- !defmacro
# Same as
"
ColumnValue
"
, but also give name of property.
# Same as
"
ColumnValue
"
, but also give name of property.
name: ColumnValuePropname
name: ColumnValuePropname
params:
params:
name: null
name: null
propname: null
propname: null
belongsto: BaseElement
type: TextElement
type: TextElement
parent: MyParent
definition:
definition:
${name}:
${name}:
type: ${type}
type: ${type}
match_name: ${name}
match_name:
^
${name}
$$
match_value: (?P<val>.*)
match_value: (?P<val>.*)
records:
records:
${
parent
}:
${
belongsto
}:
${propname}: $$val
${propname}: $$val
---
---
directory: # corresponds to the directory given to the crawler
directory: # corresponds to the directory given to the crawler
...
@@ -117,7 +135,6 @@ directory: # corresponds to the directory given to the crawler
...
@@ -117,7 +135,6 @@ directory: # corresponds to the directory given to the crawler
records:
records:
MyParent:
MyParent:
subtree: !macro
subtree: !macro
ColumnValue:
"""
"""
enums
:
dict
[
str
,
list
[
str
]]
=
{}
enums
:
dict
[
str
,
list
[
str
]]
=
{}
...
@@ -185,7 +202,7 @@ DummyRT:
...
@@ -185,7 +202,7 @@ DummyRT:
description: Note: Change name and enter description.
description: Note: Change name and enter description.
recommended_properties:
recommended_properties:
"""
"""
+
"
"
.
join
(
yaml
.
dump
(
properties
,
+
"
"
.
join
(
yaml
.
dump
(
dict
(
properties
),
# from OrderedDict to dict
allow_unicode
=
True
,
allow_unicode
=
True
,
sort_keys
=
False
).
splitlines
(
keepends
=
True
)))
sort_keys
=
False
).
splitlines
(
keepends
=
True
)))
...
@@ -209,22 +226,36 @@ DummyRT:
...
@@ -209,22 +226,36 @@ DummyRT:
myfile
.
write
(
output
)
myfile
.
write
(
output
)
if
cfood
:
if
cfood
:
defs
=
[]
defs_col_value
:
list
[
str
]
=
[]
prefix
=
"
"
*
12
defs_col_value_ref
:
list
[
str
]
=
[]
prefix
=
"
"
*
14
for
name
,
propdef
in
properties
.
items
():
for
name
,
propdef
in
properties
.
items
():
def_str
=
prefix
+
f
"
- name:
{
name
}
\n
"
dtype
=
None
dtype
=
None
reftype
=
None
defs
=
defs_col_value
# Which type?
if
propdef
[
"
datatype
"
]
==
"
DOUBLE
"
:
if
propdef
[
"
datatype
"
]
==
"
DOUBLE
"
:
dtype
=
"
FloatElement
"
dtype
=
"
FloatElement
"
elif
propdef
[
"
datatype
"
]
==
"
TEXT
"
:
elif
propdef
[
"
datatype
"
]
==
"
TEXT
"
:
dtype
=
None
dtype
=
None
else
:
else
:
dtype
=
propdef
[
"
datatype
"
]
reftype
=
propdef
[
"
datatype
"
]
defs
=
defs_col_value_ref
new_def
=
prefix
+
f
"
- name:
{
name
}
\n
"
# Append according to types:
if
reftype
:
def_str
+=
prefix
+
f
"
reftype:
{
reftype
}
\n
"
if
dtype
:
if
dtype
:
new_def
+=
prefix
+
f
"
type:
{
dtype
}
\n
"
def_str
+=
prefix
+
f
"
type:
{
dtype
}
\n
"
defs
.
append
(
new_def
)
cfood_str
+=
""
.
join
(
defs
)
# Store result
defs
.
append
(
def_str
)
del
defs
cfood_str
+=
(
prefix
[
2
:]
+
"
ColumnValue:
\n
"
+
""
.
join
(
defs_col_value
)
+
prefix
[
2
:]
+
"
ColumnValueReference:
\n
"
+
""
.
join
(
defs_col_value_ref
)
)
with
open
(
cfood
,
encoding
=
"
utf-8
"
,
mode
=
"
w
"
)
as
myfile
:
with
open
(
cfood
,
encoding
=
"
utf-8
"
,
mode
=
"
w
"
)
as
myfile
:
myfile
.
write
(
cfood_str
)
myfile
.
write
(
cfood_str
)
...
...
This diff is collapsed.
Click to expand it.
unittests/test_issues.py
+
0
−
1
View file @
43a23d05
...
@@ -24,7 +24,6 @@ from pytest import mark
...
@@ -24,7 +24,6 @@ from pytest import mark
from
caoscrawler.converters
import
replace_variables
from
caoscrawler.converters
import
replace_variables
from
caoscrawler.crawl
import
Crawler
from
caoscrawler.crawl
import
Crawler
from
caoscrawler.structure_elements
import
DictElement
from
caoscrawler.structure_elements
import
DictElement
from
caoscrawler.stores
import
GeneralStore
from
caoscrawler.stores
import
GeneralStore
from
caoscrawler.scanner
import
create_converter_registry
,
scan_structure_elements
from
caoscrawler.scanner
import
create_converter_registry
,
scan_structure_elements
...
...
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