Python 3 Fix: dict().iteritems no longer exists

Use six.iteritems() instead of dict().iteritems.

Change-Id: I53f7d18a06b8f0b8dba906824db9d2a44d4335d1
This commit is contained in:
Morgan Fainberg 2016-06-04 17:32:19 -07:00
parent 74fa3865ac
commit 05d9266c6f
2 changed files with 9 additions and 4 deletions

View File

@ -19,6 +19,9 @@ import logging
import os
import re
import six
OrderedDict = extras.try_imports(['collections.OrderedDict',
'ordereddict.OrderedDict'])
@ -59,17 +62,17 @@ class CloneMapper(object):
raise Exception("Expansion error. Check error messages above")
self.log.info("Mapping projects to workspace...")
for project, dest in ret.iteritems():
for project, dest in six.iteritems(ret):
dest = os.path.normpath(os.path.join(workspace, dest[0]))
ret[project] = dest
self.log.info(" %s -> %s", project, dest)
self.log.debug("Checking overlap in destination directories...")
check = defaultdict(list)
for project, dest in ret.iteritems():
for project, dest in six.iteritems(ret):
check[dest].append(project)
dupes = dict((d, p) for (d, p) in check.iteritems() if len(p) > 1)
dupes = dict((d, p) for (d, p) in six.iteritems(check) if len(p) > 1)
if dupes:
raise Exception("Some projects share the same destination: %s",
dupes)

View File

@ -19,6 +19,8 @@ import os
import re
import yaml
import six
from git import GitCommandError
from zuul.lib.clonemapper import CloneMapper
from zuul.merger.merger import Repo
@ -62,7 +64,7 @@ class Cloner(object):
dests = mapper.expand(workspace=self.workspace)
self.log.info("Preparing %s repositories", len(dests))
for project, dest in dests.iteritems():
for project, dest in six.iteritems(dests):
self.prepareRepo(project, dest)
self.log.info("Prepared all repositories")