Remove builtins
This commit is contained in:
parent
68a872a6cb
commit
a58510a432
|
@ -1,6 +1,5 @@
|
|||
from builtins import str
|
||||
from builtins import object
|
||||
from lxml import etree
|
||||
import six
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -39,7 +38,7 @@ class MappedXmlDocument(MappedXmlObject):
|
|||
def get_xml_tree(self):
|
||||
if self.xml_tree is None:
|
||||
parser = etree.XMLParser(remove_blank_text=True)
|
||||
if type(self.xml_str) == str:
|
||||
if type(self.xml_str) == six.binary_type:
|
||||
xml_str = self.xml_str.encode('utf8')
|
||||
else:
|
||||
xml_str = self.xml_str
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
from builtins import str
|
||||
import os
|
||||
import re
|
||||
import mimetypes
|
||||
from logging import getLogger
|
||||
|
||||
import six
|
||||
|
||||
from ckan import plugins as p
|
||||
|
||||
|
@ -121,22 +121,22 @@ class SpatialMetadata(p.SingletonPlugin):
|
|||
log.debug('Received: %r' % extra.value)
|
||||
geometry = json.loads(extra.value)
|
||||
except ValueError as e:
|
||||
error_dict = {'spatial':[u'Error decoding JSON object: %s' % str(e)]}
|
||||
error_dict = {'spatial':[u'Error decoding JSON object: %s' % six.text_type(e)]}
|
||||
raise p.toolkit.ValidationError(error_dict, error_summary=package_error_summary(error_dict))
|
||||
except TypeError as e:
|
||||
error_dict = {'spatial':[u'Error decoding JSON object: %s' % str(e)]}
|
||||
error_dict = {'spatial':[u'Error decoding JSON object: %s' % six.text_type(e)]}
|
||||
raise p.toolkit.ValidationError(error_dict, error_summary=package_error_summary(error_dict))
|
||||
|
||||
try:
|
||||
save_package_extent(package.id,geometry)
|
||||
|
||||
except ValueError as e:
|
||||
error_dict = {'spatial':[u'Error creating geometry: %s' % str(e)]}
|
||||
error_dict = {'spatial':[u'Error creating geometry: %s' % six.text_type(e)]}
|
||||
raise p.toolkit.ValidationError(error_dict, error_summary=package_error_summary(error_dict))
|
||||
except Exception as e:
|
||||
if bool(os.getenv('DEBUG')):
|
||||
raise
|
||||
error_dict = {'spatial':[u'Error: %s' % str(e)]}
|
||||
error_dict = {'spatial':[u'Error: %s' % six.text_type(e)]}
|
||||
raise p.toolkit.ValidationError(error_dict, error_summary=package_error_summary(error_dict))
|
||||
|
||||
elif (extra.state == 'active' and not extra.value) or extra.state == 'deleted':
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
from builtins import object
|
||||
import os
|
||||
import re
|
||||
|
||||
|
@ -75,4 +74,3 @@ class SpatialTestBase(object):
|
|||
@classmethod
|
||||
def teardown_class(cls):
|
||||
repo.rebuild_db()
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
from __future__ import absolute_import
|
||||
from builtins import str
|
||||
from builtins import object
|
||||
import os
|
||||
from datetime import datetime, date
|
||||
import lxml
|
||||
|
@ -815,7 +813,7 @@ class TestHarvest(HarvestFixtureBase):
|
|||
assert source_dict['status']['total_datasets'] == 1
|
||||
|
||||
def test_clean_tags(self):
|
||||
|
||||
|
||||
# Create source
|
||||
source_fixture = {
|
||||
'title': 'Test Source',
|
||||
|
@ -848,7 +846,7 @@ class TestHarvest(HarvestFixtureBase):
|
|||
context={'user': user_name},
|
||||
name='existing-group')
|
||||
|
||||
context = {'user': 'dummy'}
|
||||
context = {'user': 'dummy'}
|
||||
package_schema = default_update_package_schema()
|
||||
context['schema'] = package_schema
|
||||
package_dict = {'frequency': 'manual',
|
||||
|
@ -867,7 +865,7 @@ class TestHarvest(HarvestFixtureBase):
|
|||
'metadata_modified' : datetime.now(),
|
||||
'guid': str(uuid4()),
|
||||
'identifier': 'dummy'}
|
||||
|
||||
|
||||
package_data = call_action('package_create', context=context, **package_dict)
|
||||
|
||||
package = Package.get('fakename')
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
from builtins import object
|
||||
import os
|
||||
|
||||
from lxml import etree
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import print_function
|
||||
from builtins import str
|
||||
import os
|
||||
import sys
|
||||
|
||||
import six
|
||||
|
||||
import logging
|
||||
from ckan.lib.helpers import json
|
||||
from lxml import etree
|
||||
|
@ -22,7 +23,7 @@ def report(pkg=None):
|
|||
from ckanext.spatial.lib.reports import validation_report
|
||||
|
||||
if pkg:
|
||||
package_ref = str(pkg)
|
||||
package_ref = six.text_type(pkg)
|
||||
pkg = model.Package.get(package_ref)
|
||||
if not pkg:
|
||||
print('Package ref "%s" not recognised' % package_ref)
|
||||
|
@ -89,7 +90,7 @@ def report_csv(csv_filepath):
|
|||
|
||||
def initdb(srid=None):
|
||||
if srid:
|
||||
srid = str(srid)
|
||||
srid = six.text_type(srid)
|
||||
|
||||
from ckanext.spatial.model import setup as db_setup
|
||||
|
||||
|
@ -116,10 +117,10 @@ def update_extents():
|
|||
count += 1
|
||||
except ValueError as e:
|
||||
errors.append(u'Package %s - Error decoding JSON object: %s' %
|
||||
(package.id, str(e)))
|
||||
(package.id, six.text_type(e)))
|
||||
except TypeError as e:
|
||||
errors.append(u'Package %s - Error decoding JSON object: %s' %
|
||||
(package.id, str(e)))
|
||||
(package.id, six.text_type(e)))
|
||||
|
||||
save_package_extent(package.id, geometry)
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
from builtins import object
|
||||
import os
|
||||
from pkg_resources import resource_stream
|
||||
from ckanext.spatial.model import ISODocument
|
||||
|
|
Loading…
Reference in New Issue