Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
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
Open-Data
ckanext-odsh
Commits
6330f91b
Commit
6330f91b
authored
1 year ago
by
Thorge Petersen
Browse files
Options
Downloads
Patches
Plain Diff
Added helper functions for loading applicableLegislation and hvdCategory mappings
parent
80c45934
No related branches found
No related tags found
1 merge request
!52
Added applicableLegislation and hvdCategory support
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ckanext/odsh/helpers.py
+63
-0
63 additions, 0 deletions
ckanext/odsh/helpers.py
ckanext/odsh/plugin.py
+2
-0
2 additions, 0 deletions
ckanext/odsh/plugin.py
with
65 additions
and
0 deletions
ckanext/odsh/helpers.py
+
63
−
0
View file @
6330f91b
...
...
@@ -500,6 +500,69 @@ def short_name_for_category(category_name):
}
return
translations
.
get
(
category_name
)
def
odsh_load_applicable_legislations
():
'''
Load applicable legislations.
'''
extension_path
=
pkg_resources
.
resource_filename
(
'
ckanext.odsh
'
,
''
)
default_mapping_file_path
=
extension_path
+
'
/resources/applicable_legislations.json
'
mapping_file_path
=
config
.
get
(
'
ckanext.odsh.applicable_legislations_file_path
'
,
default_mapping_file_path
)
try
:
with
open
(
mapping_file_path
)
as
mapping_json
:
MAPPING
=
json
.
loads
(
mapping_json
.
read
(),
object_pairs_hook
=
OrderedDict
)
default
=
[{
'
value
'
:
'
Geltende Rechtsvorschrift wählen..
'
,
'
key
'
:
''
}]
options
=
[{
'
key
'
:
key
,
'
value
'
:
MAPPING
[
key
]}
for
key
in
MAPPING
]
result
=
default
+
options
except
IOError
as
err
:
log
.
error
(
'
Could not load mapping file from {}
'
.
format
(
mapping_file_path
)
)
raise
except
ValueError
as
err
:
log
.
error
(
'
Could not convert mapping file from json.
\n
Mapping file: {}
'
.
format
(
mapping_file_path
)
)
raise
return
result
def
odsh_load_hvd_categories
():
'''
Load HVD categories.
'''
extension_path
=
pkg_resources
.
resource_filename
(
'
ckanext.odsh
'
,
''
)
default_mapping_file_path
=
extension_path
+
'
/resources/hvd_categories.json
'
mapping_file_path
=
config
.
get
(
'
ckanext.odsh.hvd_categories_file_path
'
,
default_mapping_file_path
)
try
:
with
open
(
mapping_file_path
)
as
mapping_json
:
MAPPING
=
json
.
loads
(
mapping_json
.
read
(),
object_pairs_hook
=
OrderedDict
)
default
=
[{
'
value
'
:
'
HVD Kategorie wählen..
'
,
'
key
'
:
''
}]
options
=
[{
'
key
'
:
key
,
'
value
'
:
MAPPING
[
key
]}
for
key
in
MAPPING
]
result
=
default
+
options
except
IOError
as
err
:
log
.
error
(
'
Could not load mapping file from {}
'
.
format
(
mapping_file_path
)
)
raise
except
ValueError
as
err
:
log
.
error
(
'
Could not convert mapping file from json.
\n
Mapping file: {}
'
.
format
(
mapping_file_path
)
)
raise
return
result
def
odsh_load_mdk_sample_dataset
():
'''
...
...
This diff is collapsed.
Click to expand it.
ckanext/odsh/plugin.py
+
2
−
0
View file @
6330f91b
...
...
@@ -348,6 +348,8 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
'
get_resource_size
'
:
helpers_odsh
.
get_resource_size
,
'
get_address_org
'
:
helpers_odsh
.
get_address_org
,
'
get_body_mail
'
:
helpers_odsh
.
get_body_mail
,
'
odsh_load_applicable_legislations
'
:
helpers_odsh
.
odsh_load_applicable_legislations
,
'
odsh_load_hvd_categories
'
:
helpers_odsh
.
odsh_load_hvd_categories
,
'
odsh_load_mdk_sample_dataset
'
:
helpers_odsh
.
odsh_load_mdk_sample_dataset
,
'
odsh_load_raw_mdk_sample_dataset
'
:
helpers_odsh
.
odsh_load_raw_mdk_sample_dataset
,
'
format_resource_format
'
:
helpers_odsh
.
format_resource_format
,
...
...
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