Commit 9b6e9177 authored by Denis Laxalde's avatar Denis Laxalde
Browse files

[py3] Modernize

parent 1fcac766b3d4
......@@ -15,9 +15,9 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""SKOS dataimport utilities."""
from itertools import imap
from six import text_type
from six.moves import map
from cubicweb import schema
from cubicweb.dataimport.importer import (ExtEntity, ExtEntitiesImporter, RelationMapping,
......@@ -138,7 +138,7 @@ def store_skos_extentities(cnx, store, entities, import_log,
# 4. will be done in SKOSExtEntitiesImporter
return extentity
entities = imap(externaluri_to_concept, entities)
entities = map(externaluri_to_concept, entities)
# plug function to detect the concept scheme
concept_schemes = []
......@@ -147,7 +147,7 @@ def store_skos_extentities(cnx, store, entities, import_log,
concept_schemes.append(extentity.extid)
return extentity
entities = imap(record_scheme, entities)
entities = map(record_scheme, entities)
etypes_order_hint = ('ConceptScheme', 'Concept', 'Label')
existing_relations = SKOSRelationMapping(cnx, source)
importer = SKOSExtEntitiesImporter(schema=cnx.vreg.schema, store=store,
......
......@@ -15,7 +15,7 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""cubicweb-skos entity classes"""
from itertools import ifilter
from six.moves import filter
from logilab.common.decorators import cachedproperty
......@@ -162,7 +162,7 @@ class Concept(AnyEntity):
continue
else:
# Else pick a preferred label in any language.
return self.labels.values()[0]
return list(self.labels.values())[0]
def add_concept(self, label, language_code=u'en', kind=u'preferred'):
"""Add a sub-concept to this concept"""
......@@ -220,7 +220,7 @@ class AbstractRDFAdapter(EntityAdapter):
# entity to add to the graph.
entity = stack.send(related)
related = generator.add_entity(entity, self.registry)
related = ifilter(self.accept, related)
related = filter(self.accept, related)
except StopIteration:
return
......@@ -325,7 +325,7 @@ def _select_attributes(rql, var, attributes):
def _split_rset(rset, entity_col):
syntax_tree = rset.syntax_tree()
syntax_tree.copy = lambda: syntax_tree # avoid extra copy()
for entity, subrset in rset.split_rset(col=entity_col, return_dict=True).iteritems():
for entity, subrset in rset.split_rset(col=entity_col, return_dict=True).items():
subrset._rqlst = syntax_tree
yield entity, subrset
......
......@@ -62,7 +62,7 @@ class LCSV2RDF(object):
self.no_information_missing = None
self.prolog = {}
self.default_lang = default_lang
header = self.source_file.next()
header = next(self.source_file)
try:
self.prolog_column = header.index('#')
except ValueError:
......
......@@ -16,7 +16,7 @@
"""Utilities for RDF import/export"""
from os.path import abspath, splitext
from urlparse import urlparse
from six.moves.urllib.parse import urlparse
from six import PY2, text_type, string_types
......@@ -278,7 +278,7 @@ class LibRDFRDFGraph(AbstractRDFGraph):
int: 'http://www.w3.org/2001/XMLSchema#integer',
}
if PY2:
_py_xsd_map[long] = 'http://www.w3.org/2001/XMLSchema#long' # noqa
_py_xsd_map[int] = 'http://www.w3.org/2001/XMLSchema#long' # noqa
_xsd_py_map = dict((v, k) for k, v in _py_xsd_map.items())
......
......@@ -27,7 +27,8 @@ This file contains generic import code, the datafeed parser and the repository s
from hashlib import md5
from uuid import uuid4
from itertools import imap
from six.moves import map
from cubicweb import dataimport
from cubicweb.dataimport.importer import (
......@@ -143,7 +144,7 @@ def lcsv_extentities(stream, scheme_uri, delimiter=None, encoding='utf-8', langu
extentity.values.setdefault('in_scheme', set([])).add(scheme_uri)
return extentity
return imap(relate_concepts, graph_extentities(graph))
return map(relate_concepts, graph_extentities(graph))
def rdf_extentities(stream_or_url, rdf_format=None):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment