Refactor if: nesting in build_mirror

Change-Id: Ia0fe43e1f44704d5d93235ceadfcf74d00aa190b
This commit is contained in:
Yuriy Taraday
2013-12-04 16:49:41 +04:00
parent 75ed21d8a4
commit 4a87b5b172

View File

@@ -235,8 +235,7 @@ class Mirror(object):
if (not branch.startswith("remotes/origin")
or "origin/HEAD" in branch):
continue
print("Fetching pip requires for %s:%s" %
(project, branch))
print("Fetching pip requires for %s:%s" % (project, branch))
if not self.args.no_update:
self.run_command("git reset --hard %s" % branch)
self.run_command("git clean -x -f -d -q")
@@ -250,12 +249,14 @@ class Mirror(object):
"tools/test-requires"):
if os.path.exists(requires_file):
reqlist.append(requires_file)
if reqlist:
if not reqlist:
print("no requirements")
continue
self.run_command(
venv_format % dict(
extra_search_dir=pip_cache_dir, venv_dir=venv))
for requirement in [
"pip", "wheel", "virtualenv"]:
for requirement in ["pip", "wheel", "virtualenv"]:
self.run_command(
upgrade_format % dict(
pip=pip, download_cache=pip_cache_dir,
@@ -291,7 +292,8 @@ class Mirror(object):
"failed.\n%s\n" %
(project, branch, out))
print("pip install did not indicate success")
else:
continue
freeze = self.run_command("%s freeze -l" % pip)
requires = self.find_pkg_info(build)
reqfd = open(reqs, "w")
@@ -304,8 +306,7 @@ class Mirror(object):
reqfd.close()
self.run_command(venv_format % dict(
extra_search_dir=pip_cache_dir, venv_dir=venv))
for requirement in [
"pip", "wheel"]:
for requirement in ["pip", "wheel"]:
self.run_command(
upgrade_format % dict(
pip=pip, download_cache=pip_cache_dir,
@@ -333,11 +334,8 @@ class Mirror(object):
if self.args.export_file:
print("Export installed package list to " +
self.args.export_file)
with open(self.args.export_file, "w") \
as package_list_file:
with open(self.args.export_file, "w") as package_list_file:
package_list_file.write(freeze)
else:
print("no requirements")
shutil.rmtree(workdir)
def _get_distro(self):