[dataimport] Format strings with % instead of .format()
For consistency with CubicWeb code base and to avoid Python 2.6
compatibility traps.
--- a/dataimport/deprecated.py Mon Nov 30 10:18:22 2015 +0100
+++ b/dataimport/deprecated.py Mon Nov 30 11:09:51 2015 +0100
@@ -294,7 +294,7 @@
"""Given an entity type and eid, updates the corresponding fake entity with specified
attributes and inlined relations.
"""
- assert eid in self.types[etype], 'Trying to update with wrong type {}'.format(etype)
+ assert eid in self.types[etype], 'Trying to update with wrong type %s' % etype
data = self.eids[eid]
data.update(kwargs)
--- a/dataimport/importer.py Mon Nov 30 10:18:22 2015 +0100
+++ b/dataimport/importer.py Mon Nov 30 11:09:51 2015 +0100
@@ -83,15 +83,15 @@
def __init__(self, cnx, source=None):
self.cnx = cnx
- self._rql_template = 'Any S,O WHERE S {} O'
+ self._rql_template = 'Any S,O WHERE S %s O'
self._kwargs = {}
if source is not None:
- self._rql_template += ', S cw_source SO, O cw_source SO, SO eid %(s)s'
+ self._rql_template += ', S cw_source SO, O cw_source SO, SO eid %%(s)s'
self._kwargs['s'] = source.eid
def __getitem__(self, rtype):
"""Return a set of (subject, object) eids already related by `rtype`"""
- rql = self._rql_template.format(rtype)
+ rql = self._rql_template % rtype
return set(tuple(x) for x in self.cnx.execute(rql, self._kwargs))
--- a/dataimport/stores.py Mon Nov 30 10:18:22 2015 +0100
+++ b/dataimport/stores.py Mon Nov 30 11:09:51 2015 +0100
@@ -103,7 +103,7 @@
and inlined relations.
"""
entity = self._cnx.entity_from_eid(eid)
- assert entity.cw_etype == etype, 'Trying to update with wrong type {}'.format(etype)
+ assert entity.cw_etype == etype, 'Trying to update with wrong type %s' % etype
# XXX some inlined relations may already exists
entity.cw_set(**kwargs)