Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ckan 2.11 support + various updates #270

Merged
merged 6 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.7'
python-version: '3.9'
- name: Install requirements
run: pip install flake8 pycodestyle
- name: Check syntax
Expand All @@ -17,13 +17,13 @@ jobs:
needs: lint
strategy:
matrix:
ckan-version: ["2.10", 2.9]
ckan-version: ["master", "2.10", 2.9]
fail-fast: false

name: CKAN ${{ matrix.ckan-version }}
runs-on: ubuntu-latest
container:
image: openknowledge/ckan-dev:${{ matrix.ckan-version }}
image: ckan/ckan-dev:${{ matrix.ckan-version }}
services:
solr:
image: ckan/ckan-solr:${{ matrix.ckan-version }}
Expand All @@ -44,7 +44,7 @@ jobs:
CKAN_REDIS_URL: redis://redis:6379/1

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install requirements
run: |
pip install -r requirements.txt
Expand All @@ -66,6 +66,8 @@ jobs:
- name: Run tests
run: pytest --ckan-ini=test.ini --cov=ckanext.dcat --cov-report=xml --cov-append --disable-warnings ckanext/dcat/tests
- name: Upload coverage report to codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
files: ./coverage.xml
env:
token: ${{ secrets.CODECOV_TOKEN }}
16 changes: 6 additions & 10 deletions ckanext/dcat/profiles.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from builtins import str
from past.builtins import basestring
from builtins import object
import datetime
import json

Expand All @@ -20,6 +17,7 @@
from ckan.model.license import LicenseRegister
from ckan.plugins import toolkit
from ckan.lib.munge import munge_tag
from ckan.lib.helpers import resource_formats
from ckanext.dcat.utils import resource_uri, publisher_uri_organization_fallback, DCAT_EXPOSE_SUBCATALOGS, DCAT_CLEAN_TAGS

DCT = Namespace("http://purl.org/dc/terms/")
Expand Down Expand Up @@ -67,7 +65,7 @@ class URIRefOrLiteral(object):
def __new__(cls, value):
try:
stripped_value = value.strip()
if (isinstance(value, basestring) and (stripped_value.startswith("http://")
if (isinstance(value, str) and (stripped_value.startswith("http://")
or stripped_value.startswith("https://"))):
uri_obj = CleanedURIRef(value)
# although all invalid chars checked by rdflib should have been quoted, try to serialize
Expand Down Expand Up @@ -101,7 +99,7 @@ def _careful_quote(value):
return value

def __new__(cls, value):
if isinstance(value, basestring):
if isinstance(value, str):
value = CleanedURIRef._careful_quote(value.strip())
return URIRef(value)

Expand Down Expand Up @@ -614,7 +612,7 @@ def _distribution_format(self, distribution, normalize_ckan_format=True):
if self._object(_format, RDF.type) == DCT.IMT:
if not imt:
imt = str(self.g.value(_format, default=None))
label = str(self.g.label(_format, default=None))
label = self._object_value(_format, RDFS.label)
elif isinstance(_format, URIRef):
# If the URIRef does not reference a BNode, it could reference an IANA type.
# Otherwise, use it as label.
Expand All @@ -625,10 +623,8 @@ def _distribution_format(self, distribution, normalize_ckan_format=True):
label = format_uri

if ((imt or label) and normalize_ckan_format):
import ckan.config
from ckan.lib import helpers

format_registry = helpers.resource_formats()
format_registry = resource_formats()

if imt in format_registry:
label = format_registry[imt][1]
Expand Down Expand Up @@ -662,7 +658,7 @@ def _read_list_value(self, value):
# List of values
if isinstance(value, list):
items = value
elif isinstance(value, basestring):
elif isinstance(value, str):
try:
items = json.loads(value)
if isinstance(items, ((int, float, complex))):
Expand Down
3 changes: 1 addition & 2 deletions ckanext/dcat/templates/package/read_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{% endwith %}
{% endif %}
{% endblock -%}
{% block body_extras %}
{% block scripts %}
{{ super() }}
{% block structured_data %}
{#
Expand All @@ -22,7 +22,6 @@
More information about structured data:
https://developers.google.com/search/docs/guides/intro-structured-data
#}

{% if h.helper_available('structured_data') %}
<script type="application/ld+json">
{{ h.structured_data(pkg.id)|safe }}
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rdflib==6.1.1
rdflib>=6.1.1,<7.1.0
geomet>=0.2.0
ckantoolkit>=0.0.7
future>=0.18.2
future>=0.18.2
Loading