Commit a8f4ba7a authored by Rémi Cardona's avatar Rémi Cardona
Browse files

[py3k] dict.iteritems → dict.items

parent e6eb0c7c2e98
......@@ -506,7 +506,7 @@ this option is set to yes",
deps = {}
deps = dict( (x[len('cubicweb-'):], v)
for x, v in gendeps.iteritems()
for x, v in gendeps.items()
if x.startswith('cubicweb-'))
for depcube in deps:
......@@ -773,7 +773,7 @@ given, appropriate sources for migration will be automatically selected \
vcconf = repo.get_versions()
helper = self.config_helper(config, required=False)
if self.config.force_cube_version:
for cube, version in self.config.force_cube_version.iteritems():
for cube, version in self.config.force_cube_version.items():
vcconf[cube] = Version(version)
toupgrade = []
for cube in config.cubes():
......@@ -1049,7 +1049,7 @@ class ConfigureInstanceCommand(InstanceCommand):
def configure_instance(self, appid):
if self.config.param is not None:
appcfg = cwcfg.config_for(appid)
for key, value in self.config.param.iteritems():
for key, value in self.config.param.items():
appcfg.global_set_option(key, value)
except KeyError:
......@@ -382,7 +382,7 @@ class CWRegistryStore(RegistryStore):
return [item for item in super(CWRegistryStore, self).items()
if not item[0] in ('propertydefs', 'propertyvalues')]
def iteritems(self):
return (item for item in super(CWRegistryStore, self).iteritems()
return (item for item in super(CWRegistryStore, self).items()
if not item[0] in ('propertydefs', 'propertyvalues'))
def values(self):
......@@ -576,7 +576,7 @@ class CWRegistryStore(RegistryStore):
if withsitewide:
return sorted(k for k in self['propertydefs']
if not k.startswith('sources.'))
return sorted(k for k, kd in self['propertydefs'].iteritems()
return sorted(k for k, kd in self['propertydefs'].items()
if not kd['sitewide'] and not k.startswith('sources.'))
def register_property(self, key, type, help, default=None, vocabulary=None,
......@@ -348,7 +348,7 @@ class SQLGenSourceWrapper(object):
# In that case, simply update the insert dict and remove
# the need to make the
# UPDATE statement
for statement, datalist in _inlined_relations_sql.iteritems():
for statement, datalist in _inlined_relations_sql.items():
new_datalist = []
# for a given inlined relation,
# browse each couple to be inserted
......@@ -168,7 +168,7 @@ class NoHookRQLObjectStore(RQLObjectStore):
"""Given an entity type, attributes and inlined relations, returns the inserted entity's
for k, v in kwargs.iteritems():
for k, v in kwargs.items():
kwargs[k] = getattr(v, 'eid', v)
entity, rels = self.metagen.base_etype_dicts(etype)
# make a copy to keep cached entity pristine
......@@ -183,7 +183,7 @@ class NoHookRQLObjectStore(RQLObjectStore):
kwargs = dict()
if inspect.getargspec(self.add_relation).keywords:
kwargs['subjtype'] = entity.cw_etype
for rtype, targeteids in rels.iteritems():
for rtype, targeteids in rels.items():
# targeteids may be a single eid or a list of eids
inlined = self.rschema(rtype).inlined
......@@ -465,7 +465,7 @@ class TestDataBaseHandler(object):
dbname, data = data.split('-', 1)
db_id, filetype = data.split('.', 1)
entries.setdefault((dbname, db_id), {})[filetype] = filepath
for (dbname, db_id), entry in entries.iteritems():
for (dbname, db_id), entry in entries.items():
# apply necessary transformation from the driver
value = self.process_cache_entry(directory, dbname, db_id, entry)
assert 'config' in entry
......@@ -733,7 +733,7 @@ class ExamineLogCommand(Command):
except Exception as exc:
sys.stderr.write('Line %s: %s (%s)\n' % (lineno, exc, line))
stat = []
for rql, times in requests.iteritems():
for rql, times in requests.items():
stat.append( (sum(time[0] for time in times),
sum(time[1] for time in times),
len(times), rql) )
......@@ -112,7 +112,7 @@ class FakeRequest(ConnectionCubicWebRequestBase):
def build_url_params(self, **kwargs):
# overriden to get predictable resultts
args = []
for param, values in sorted(kwargs.iteritems()):
for param, values in sorted(kwargs.items()):
if not isinstance(values, (list, tuple)):
values = (values,)
for value in values:
......@@ -209,7 +209,7 @@ class PageInfo(object):
def matching_nodes(self, tag, **attrs):
for elt in self.etree.iterfind(self._iterstr(tag)):
eltattrs = elt.attrib
for attr, value in attrs.iteritems():
for attr, value in attrs.items():
if eltattrs[attr] != value:
......@@ -186,7 +186,7 @@ class PropagationAnalyzer(object):
def add_colors_legend(self, graph):
"""Add a legend of used colors to the graph."""
for package, color in sorted(_COLORS.iteritems()):
for package, color in sorted(_COLORS.items()):
graph.add_node(package, color=color, fontcolor=color, shape='record')
......@@ -307,8 +307,8 @@ def _build_variantes(self, newsolutions):
variantes = _orig_build_variantes(self, newsolutions)
sortedvariantes = []
for variante in variantes:
orderedkeys = sorted((k[1], k[2], v) for k, v in variante.iteritems())
variante = DumbOrderedDict(sorted(variante.iteritems(),
orderedkeys = sorted((k[1], k[2], v) for k, v in variante.items())
variante = DumbOrderedDict(sorted(variante.items(),
lambda a, b: cmp((a[0][1],a[0][2],a[1]),
sortedvariantes.append( (orderedkeys, variante) )
......@@ -319,7 +319,7 @@ _orig_check_permissions = ExecutionPlan._check_permissions
def _check_permissions(*args, **kwargs):
res, restricted = _orig_check_permissions(*args, **kwargs)
res = DumbOrderedDict(sorted(res.iteritems(), lambda a, b: cmp(a[1], b[1])))
res = DumbOrderedDict(sorted(res.items(), lambda a, b: cmp(a[1], b[1])))
return res, restricted
def _dummy_check_permissions(self, rqlst):
......@@ -521,10 +521,10 @@ class CubicWebTC(TestCase):
similar to `orig_permissions.update(partial_perms)`.
torestore = []
for erschema, etypeperms in chain(perm_overrides, perm_kwoverrides.iteritems()):
for erschema, etypeperms in chain(perm_overrides, perm_kwoverrides.items()):
if isinstance(erschema, string_types):
erschema = self.schema[erschema]
for action, actionperms in etypeperms.iteritems():
for action, actionperms in etypeperms.items():
origperms = erschema.permissions[action]
erschema.set_action_permissions(action, actionperms)
torestore.append([erschema, action, origperms])
......@@ -887,7 +887,7 @@ class CubicWebTC(TestCase):
# maps vid : validator name (override content_type_validators)
vid_validators = dict((vid, htmlparser.VALMAP[valkey])
for vid, valkey in VIEW_VALIDATORS.iteritems())
for vid, valkey in VIEW_VALIDATORS.items())
def view(self, vid, rset=None, req=None, template='main-template',
......@@ -1106,7 +1106,7 @@ def how_many_dict(schema, cnx, how_many, skip):
# new num for etype = max(current num, sum(num for possible target etypes))
# XXX we should first check there is no cycle then propagate changes
for (rschema, etype), targets in relmap.iteritems():
for (rschema, etype), targets in relmap.items():
relfactor = sum(howmanydict[e] for e in targets)
howmanydict[str(etype)] = max(relfactor, howmanydict[etype])
return howmanydict
......@@ -1314,7 +1314,7 @@ def not_selected(vreg, appobject):
# def print_untested_objects(testclass, skipregs=('hooks', 'etypes')):
# for regname, reg in testclass._env.vreg.iteritems():
# for regname, reg in testclass._env.vreg.items():
# if regname in skipregs:
# continue
# for appobjects in reg.itervalues():
......@@ -95,7 +95,7 @@ def diseasome_import(session, file_name, store):
# Perform a first commit, of the entities
kwargs = {}
for uri, relations in all_relations.iteritems():
for uri, relations in all_relations.items():
from_eid = uri_to_eid.get(uri)
# ``subjtype`` should be initialized if ``SQLGenObjectStore`` is used
# and there are inlined relations in the schema.
......@@ -108,7 +108,7 @@ def diseasome_import(session, file_name, store):
kwargs['subjtype'] = uri_to_etype.get(uri)
if not from_eid:
for rtype, rels in relations.iteritems():
for rtype, rels in relations.items():
if rtype in ('classes', 'possible_drugs', 'omim', 'omim_page',
'chromosomal_location', 'same_as', 'gene_id',
'hgnc_id', 'hgnc_page'):
......@@ -162,7 +162,7 @@ class IFTIndexableAdapter(view.EntityAdapter):
return words
def merge_weight_dict(maindict, newdict):
for weight, words in newdict.iteritems():
for weight, words in newdict.items():
maindict.setdefault(weight, []).extend(words)
class IDownloadableAdapter(view.EntityAdapter):
......@@ -42,7 +42,7 @@ class _CWSourceCfgMixIn(object):
options = SOURCE_TYPES[self.type].options
sconfig = SourceConfiguration(self._cw.vreg.config, options=options)
for opt, val in cfg.iteritems():
for opt, val in cfg.items():
sconfig.set_option(opt, val)
except OptionError:
......@@ -60,7 +60,7 @@ class MetadataTC(BaseEntityTC):
# XXX move to yams
self.assertEqual(self.schema['CWUser'].meta_attributes(), {})
self.assertEqual(dict((str(k), v)
for k, v in self.schema['State'].meta_attributes().iteritems()),
for k, v in self.schema['State'].meta_attributes().items()),
{'description_format': ('format', 'description')})
def test_fti_rql_method(self):
......@@ -108,7 +108,7 @@ def build_cstr_with_linkto_infos(cstr, args, searchedvar, evar,
st = cstr.snippet_rqlst.copy()
# replace relations in ST by eid infos from linkto where possible
for (info_rtype, info_role), eids in lt_infos.iteritems():
for (info_rtype, info_role), eids in lt_infos.items():
eid = eids[0] # NOTE: we currently assume a pruned lt_info with only 1 eid
for rel in st.iget_nodes(RqlRelation):
targetvar = rel_matches(rel, info_rtype, info_role,
......@@ -135,7 +135,7 @@ def build_cstr_with_linkto_infos(cstr, args, searchedvar, evar,
def pruned_lt_info(eschema, lt_infos):
pruned = {}
for (lt_rtype, lt_role), eids in lt_infos.iteritems():
for (lt_rtype, lt_role), eids in lt_infos.items():
# we can only use lt_infos describing relation with a cardinality
# of value 1 towards the linked entity
if not len(eids) == 1:
......@@ -31,7 +31,7 @@ class CubicWebTwistedRequestAdapter(CubicWebRequestBase):
self._twreq = req
super(CubicWebTwistedRequestAdapter, self).__init__(
vreg, https, req.args, headers=req.received_headers)
for key, name_stream_list in req.files.iteritems():
for key, name_stream_list in req.files.items():
for name, stream in name_stream_list:
if name is not None:
name = unicode(name, self.encoding)
......@@ -221,7 +221,7 @@ class RestTC(CubicWebTC):
""" % {'rql': rql,
'colvids': ', '.join(["%d=%s" % (k, v)
for k, v in colvids.iteritems()])
for k, v in colvids.items()])
view = self.vreg['views'].select('table', req, rset=req.execute(rql))
view.cellvids = colvids
......@@ -52,7 +52,7 @@ class UpdateFeedsStartupHook(hook.Hook):
def update_feeds(repo):
# take a list to avoid iterating on a dictionary whose size may
# change
for uri, source in list(repo.sources_by_uri.iteritems()):
for uri, source in list(repo.sources_by_uri.items()):
if (uri == 'system'
or not repo.config.source_enabled(source)
or not source.config['synchronize']):
......@@ -72,7 +72,7 @@ class DataImportsCleanupStartupHook(hook.Hook):
def __call__(self):
def expire_dataimports(repo=self.repo):
for uri, source in repo.sources_by_uri.iteritems():
for uri, source in repo.sources_by_uri.items():
if (uri == 'system'
or not repo.config.source_enabled(source)):
Supports Markdown
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