[createrepo-wrapper] Refactor code

Simplify the code a bit by removing conditions that don't help in any
way: executing a loop zero times is the same as not executing it at all.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-02-29 10:43:54 +01:00
parent d619f14dbf
commit 6ae48e2bf5

View File

@ -28,15 +28,15 @@ class CreaterepoWrapper(object):
self.mergerepo = "mergerepo"
self.modifyrepo = "modifyrepo"
def get_createrepo_cmd(self, directory, baseurl=None, outputdir=None, excludes=None, pkglist=None, groupfile=None, cachedir=None,
update=True, update_md_path=None, skip_stat=False, checkts=False, split=False, pretty=True, database=True, checksum=None,
unique_md_filenames=True, distro=None, content=None, repo=None, revision=None, deltas=False, oldpackagedirs=None,
num_deltas=None, workers=None):
def get_createrepo_cmd(self, directory, baseurl=None, outputdir=None, excludes=None,
pkglist=None, groupfile=None, cachedir=None, update=True,
update_md_path=None, skip_stat=False, checkts=False, split=False,
pretty=True, database=True, checksum=None, unique_md_filenames=True,
distro=None, content=None, repo=None, revision=None, deltas=False,
oldpackagedirs=None, num_deltas=None, workers=None):
# groupfile = /path/to/comps.xml
cmd = [self.createrepo]
cmd.append(directory)
cmd = [self.createrepo, directory]
if baseurl:
cmd.append("--baseurl=%s" % baseurl)
@ -44,8 +44,7 @@ class CreaterepoWrapper(object):
if outputdir:
cmd.append("--outputdir=%s" % outputdir)
if excludes:
for i in force_list(excludes):
for i in force_list(excludes or []):
cmd.append("--excludes=%s" % i)
if pkglist:
@ -91,16 +90,13 @@ class CreaterepoWrapper(object):
else:
cmd.append("--simple-md-filenames")
if distro:
for i in force_list(distro):
for i in force_list(distro or []):
cmd.append("--distro=%s" % i)
if content:
for i in force_list(content):
for i in force_list(content or []):
cmd.append("--content=%s" % i)
if repo:
for i in force_list(repo):
for i in force_list(repo or []):
cmd.append("--repo=%s" % i)
if revision:
@ -109,8 +105,7 @@ class CreaterepoWrapper(object):
if deltas:
cmd.append("--deltas")
if oldpackagedirs:
for i in force_list(oldpackagedirs):
for i in force_list(oldpackagedirs or []):
cmd.append("--oldpackagedirs=%s" % i)
if num_deltas: