Skip to content

Commit

Permalink
Remove old py2 compat stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Apr 19, 2024
1 parent f124619 commit 39b033b
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 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 @@ -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

0 comments on commit 39b033b

Please sign in to comment.