# HG changeset patch # User Denis Laxalde # Date 1448878191 -3600 # Node ID b30c2f49da573eb19f75962c5ea65e834965e542 # Parent a24a13742f3c264f2d28117c3b05fc677bd093a4 [dataimport] Format strings with % instead of .format() For consistency with CubicWeb code base and to avoid Python 2.6 compatibility traps. diff -r a24a13742f3c -r b30c2f49da57 dataimport/deprecated.py --- 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) diff -r a24a13742f3c -r b30c2f49da57 dataimport/importer.py --- 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)) diff -r a24a13742f3c -r b30c2f49da57 dataimport/stores.py --- 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)