diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d782292f..c4312706 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 @@ -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 }} @@ -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 @@ -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 }} diff --git a/ckanext/dcat/profiles.py b/ckanext/dcat/profiles.py index 450166b0..c1ced34f 100644 --- a/ckanext/dcat/profiles.py +++ b/ckanext/dcat/profiles.py @@ -1,6 +1,3 @@ -from builtins import str -from past.builtins import basestring -from builtins import object import datetime import json @@ -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/") @@ -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 @@ -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) @@ -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. @@ -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] @@ -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))): diff --git a/ckanext/dcat/templates/package/read_base.html b/ckanext/dcat/templates/package/read_base.html index 6d2216f1..4c6023c6 100644 --- a/ckanext/dcat/templates/package/read_base.html +++ b/ckanext/dcat/templates/package/read_base.html @@ -12,7 +12,7 @@ {% endwith %} {% endif %} {% endblock -%} -{% block body_extras %} +{% block scripts %} {{ super() }} {% block structured_data %} {# @@ -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') %}