Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
ckanext-odsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Transparenzportal
ckanext-odsh
Commits
b9634780
Commit
b9634780
authored
6 years ago
by
Rainer Herzog
Browse files
Options
Downloads
Patches
Plain Diff
Also accept datasets from Statistikamt Nord without temporal_start/end
parent
c48f741d
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ckanext/odsh/harvesters/statistikamtnordharvester.py
+11
-21
11 additions, 21 deletions
ckanext/odsh/harvesters/statistikamtnordharvester.py
ckanext/odsh/plugin.py
+11
-8
11 additions, 8 deletions
ckanext/odsh/plugin.py
with
22 additions
and
29 deletions
ckanext/odsh/harvesters/statistikamtnordharvester.py
+
11
−
21
View file @
b9634780
...
@@ -125,19 +125,6 @@ class StatistikamtNordHarvester(ODSHBaseHarvester):
...
@@ -125,19 +125,6 @@ class StatistikamtNordHarvester(ODSHBaseHarvester):
self
.
map_fields
(
context
,
harvest_object
)
self
.
map_fields
(
context
,
harvest_object
)
return
True
return
True
@staticmethod
def
_update_schema
(
schema
):
schema
.
update
({
'
temporal_start
'
:
[
toolkit
.
get_validator
(
'
ignore_empty
'
),
toolkit
.
get_converter
(
'
convert_to_extras
'
)]})
schema
.
update
({
'
temporal_end
'
:
[
toolkit
.
get_validator
(
'
ignore_empty
'
),
toolkit
.
get_converter
(
'
convert_to_extras
'
)]})
schema
.
update
({
'
issued
'
:
[
toolkit
.
get_validator
(
'
ignore_missing
'
),
toolkit
.
get_validator
(
'
ignore_empty
'
),
toolkit
.
get_converter
(
'
convert_to_extras
'
)]})
def
map_fields
(
self
,
context
,
harvest_object
):
def
map_fields
(
self
,
context
,
harvest_object
):
values
=
json
.
loads
(
harvest_object
.
content
)
values
=
json
.
loads
(
harvest_object
.
content
)
...
@@ -176,9 +163,7 @@ class StatistikamtNordHarvester(ODSHBaseHarvester):
...
@@ -176,9 +163,7 @@ class StatistikamtNordHarvester(ODSHBaseHarvester):
try
:
try
:
context
=
{
'
user
'
:
self
.
_get_user_name
(),
'
return_id_only
'
:
True
,
'
ignore_auth
'
:
True
}
context
=
{
'
user
'
:
self
.
_get_user_name
(),
'
return_id_only
'
:
True
,
'
ignore_auth
'
:
True
}
package_plugin
=
lib_plugins
.
lookup_package_plugin
(
package_dict
.
get
(
'
type
'
,
None
))
package_plugin
=
lib_plugins
.
lookup_package_plugin
(
package_dict
.
get
(
'
type
'
,
None
))
package_schema
=
package_plugin
.
create_package_schema
()
context
[
'
schema
'
]
=
package_plugin
.
create_package_schema
()
self
.
_update_schema
(
package_schema
)
context
[
'
schema
'
]
=
package_schema
self
.
_handle_current_harvest_object
(
harvest_object
,
harvest_object
.
guid
)
self
.
_handle_current_harvest_object
(
harvest_object
,
harvest_object
.
guid
)
result
=
toolkit
.
get_action
(
'
package_create
'
)(
context
,
package_dict
)
result
=
toolkit
.
get_action
(
'
package_create
'
)(
context
,
package_dict
)
return
result
return
result
...
@@ -190,11 +175,16 @@ class StatistikamtNordHarvester(ODSHBaseHarvester):
...
@@ -190,11 +175,16 @@ class StatistikamtNordHarvester(ODSHBaseHarvester):
def
add_extras
(
package_dict
,
values
):
def
add_extras
(
package_dict
,
values
):
# issued sollte noch geliefert werden!
# issued sollte noch geliefert werden!
package_dict
[
'
extras
'
].
append
({
package_dict
[
'
extras
'
].
append
({
'
key
'
:
'
issued
'
,
'
value
'
:
datetime
.
datetime
.
now
().
isoformat
().
split
(
'
T
'
)[
0
]})
'
key
'
:
'
issued
'
,
'
value
'
:
datetime
.
datetime
.
now
().
isoformat
()})
try
:
if
values
[
'
ZeitraumVon
'
]
!=
""
:
package_dict
[
'
extras
'
].
append
({
package_dict
[
'
extras
'
].
append
({
'
key
'
:
'
temporal_start
'
,
'
value
'
:
values
[
'
ZeitraumVon
'
]})
'
key
'
:
'
temporal_start
'
,
'
value
'
:
values
[
'
ZeitraumVon
'
]})
if
values
[
'
ZeitraumBis
'
]
!=
""
:
package_dict
[
'
extras
'
].
append
({
package_dict
[
'
extras
'
].
append
({
'
key
'
:
'
temporal_end
'
,
'
value
'
:
values
[
'
ZeitraumBis
'
]})
'
key
'
:
'
temporal_end
'
,
'
value
'
:
values
[
'
ZeitraumBis
'
]})
except
KeyError
as
kerr
:
log
.
debug
(
"
Date not available:
"
+
str
(
kerr
))
package_dict
[
'
extras
'
].
append
({
package_dict
[
'
extras
'
].
append
({
'
key
'
:
'
spatial_uri
'
,
'
value
'
:
'
http://dcat-ap.de/def/politicalGeocoding/stateKey/01
'
})
'
key
'
:
'
spatial_uri
'
,
'
value
'
:
'
http://dcat-ap.de/def/politicalGeocoding/stateKey/01
'
})
package_dict
[
'
extras
'
].
append
({
package_dict
[
'
extras
'
].
append
({
...
...
This diff is collapsed.
Click to expand it.
ckanext/odsh/plugin.py
+
11
−
8
View file @
b9634780
...
@@ -129,12 +129,15 @@ def odsh_validate_extra_date(key, field, data, errors, context):
...
@@ -129,12 +129,15 @@ def odsh_validate_extra_date(key, field, data, errors, context):
value
=
_extract_value
(
key
,
data
,
field
)
value
=
_extract_value
(
key
,
data
,
field
)
if
not
value
:
if
not
value
:
# Statistikamt Nord does not always provide temporal_start/end,
# but their datasets have to be accepted as they are.
if
data
[(
'
id
'
,)][:
7
]
!=
'
StaNord
'
:
raise
toolkit
.
Invalid
(
field
+
'
:odsh_
'
+
field
+
'
_error_label
'
)
raise
toolkit
.
Invalid
(
field
+
'
:odsh_
'
+
field
+
'
_error_label
'
)
else
:
try
:
try
:
# date.split('T')[0] will yield "2012-01-01"
# date.split('T')[0] will yield "2012-01-01"
# no matter if the date is like "2012-01-01" or "2012-01-01T00:00:00"
# no matter if the date is like "2012-01-01" or "2012-01-01T00:00:00"
datetime
.
datetime
.
strptime
(
value
.
split
(
'
T
'
)[
0
],
'
%Y-%m-%d
'
)
datetime
.
datetime
.
strptime
(
value
.
split
(
'
T
'
)[
0
],
'
%Y-%m-%d
'
)
.
isoformat
()
except
ValueError
:
except
ValueError
:
raise
toolkit
.
Invalid
(
field
+
'
:odsh_
'
+
field
+
'
_not_date_error_label
'
)
raise
toolkit
.
Invalid
(
field
+
'
:odsh_
'
+
field
+
'
_not_date_error_label
'
)
...
...
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