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