1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-08 22:06:16 +01:00

Use a more readable 'if ... in ' construct

This commit is contained in:
Dirk Mueller 2022-09-30 14:09:37 +02:00
parent b92f9f76ef
commit 4edd4799a1
2 changed files with 19 additions and 19 deletions

View File

@ -107,7 +107,7 @@ class Buildinfo:
# are we building .rpm or .deb?
# XXX: shouldn't we deliver the type via the buildinfo?
self.pacsuffix = 'rpm'
if self.buildtype == 'dsc' or self.buildtype == 'collax' or self.binarytype == 'deb':
if self.buildtype in ('dsc', 'collax', 'deb'):
self.pacsuffix = 'deb'
if self.buildtype == 'arch':
self.pacsuffix = 'arch'
@ -390,7 +390,7 @@ def get_built_files(pacdir, buildtype):
'-type', 'f'],
stdout=subprocess.PIPE).stdout.read().strip()
s_built = ''
elif buildtype == 'dsc' or buildtype == 'collax':
elif buildtype in ('dsc', 'collax'):
b_built = subprocess.Popen(['find', os.path.join(pacdir, 'DEBS'),
'-name', '*.deb'],
stdout=subprocess.PIPE).stdout.read().strip()
@ -476,7 +476,7 @@ def get_prefer_pkgs(dirs, wanted_arch, type, cpio):
repositories = []
suffix = '*.rpm'
if type == 'dsc' or type == 'collax' or type == 'livebuild':
if type in ('dsc', 'collax', 'livebuild'):
suffix = '*.deb'
elif type == 'arch':
suffix = '*.pkg.tar.*'
@ -1196,7 +1196,7 @@ def main(apiurl, opts, argv):
buildargs.append('--oldpackages=%s' % old_pkg_dir)
# Make packages from buildinfo available as repos for kiwi/docker/fissile
if build_type == 'kiwi' or build_type == 'docker' or build_type == 'podman' or build_type == 'fissile':
if build_type in ('kiwi', 'docker', 'podman', 'fissile'):
if os.path.exists('repos'):
shutil.rmtree('repos')
if os.path.exists('containers'):
@ -1326,7 +1326,7 @@ def main(apiurl, opts, argv):
buildargs.append('--kiwi-parameter')
buildargs.append('--add-repopriority=' + xml.get('priority'))
if vm_type == "xen" or vm_type == "kvm" or vm_type == "lxc" or vm_type == "nspawn":
if vm_type in ('xen', 'kvm', 'lxc', 'nspawn'):
print('Skipping verification of package signatures due to secure VM build')
elif bi.pacsuffix == 'rpm':
if opts.no_verify:
@ -1359,7 +1359,7 @@ def main(apiurl, opts, argv):
print('Writing build configuration')
if build_type == 'kiwi' or build_type == 'docker' or build_type == 'podman' or build_type == 'fissile':
if build_type in ('kiwi', 'docker', 'podman', 'fissile'):
rpmlist = ['%s %s\n' % (i.name, i.fullfilename) for i in bi.deps if not i.noinstall]
else:
rpmlist = []

View File

@ -3549,12 +3549,12 @@ Please submit there instead, or use --nodevelproject to force direct submission.
osc bco ...
"""
if subcmd == 'getpac' or subcmd == 'branchco' or subcmd == 'bco':
if subcmd in ('getpac', 'branchco', 'bco'):
opts.checkout = True
args = slash_split(args)
tproject = tpackage = None
if (subcmd == 'getpac' or subcmd == 'bco') and len(args) == 1:
if subcmd in ('getpac', 'bco') and len(args) == 1:
def_p = find_default_project(self.get_api_url(), args[0])
print('defaulting to %s/%s' % (def_p, args[0]), file=sys.stderr)
# python has no args.unshift ???
@ -3877,7 +3877,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
Compare a package against the link base (ignoring working copy changes).
"""
if (subcmd == 'ldiff' or subcmd == 'linkdiff'):
if (subcmd in ('ldiff', 'linkdiff')):
opts.link = True
args = parseargs(args)
@ -5139,7 +5139,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
continue
if state == '?':
sys.exit('\'%s\' is not under version control' % filename)
elif state in ['A', 'M'] and not opts.force:
elif state in ('A', 'M') and not opts.force:
sys.exit('\'%s\' has local modifications (use --force to remove this file)' % filename)
elif state == 'S':
sys.exit('\'%s\' is marked as skipped and no local file with this name exists' % filename)
@ -5481,7 +5481,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
package = package + ":" + opts.multibuild_package
offset = 0
if subcmd == "blt" or subcmd == "buildlogtail":
if subcmd in ("blt", "buildlogtail"):
query = {'view': 'entry'}
if opts.last:
query['last'] = 1
@ -5575,7 +5575,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
package = package + ":" + opts.multibuild_package
offset = 0
if subcmd == "rblt" or subcmd == "rbuildlogtail" or subcmd == "remotebuildlogtail":
if subcmd in ("rblt", "rbuildlogtail", "remotebuildlogtail"):
query = {'view': 'entry'}
if opts.last:
query['last'] = 1
@ -6115,7 +6115,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
# it seems to be an architecture in general
arg_arch = arg
if not (arg == osc_build.hostarch or arg in osc_build.can_also_build.get(osc_build.hostarch, [])):
if not (vm_type == 'qemu' or vm_type == 'emulator'):
if vm_type not in ('qemu', 'emulator'):
print("WARNING: native compile is not possible, a emulator via binfmt misc handler must be configured!")
elif not arg_repository:
arg_repository = arg
@ -6898,7 +6898,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if command not in ('runall', 'ra', 'run', 'localrun', 'manualrun', 'disabledrun', 'remoterun', 'lr', 'dr', 'mr', 'rr', 'merge', 'wait'):
raise oscerr.WrongArgs('Wrong command given.')
if command == "remoterun" or command == "rr":
if command in ('remoterun', 'rr'):
print(runservice(apiurl, project, package))
return
@ -6914,13 +6914,13 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if not is_package_dir(os.curdir):
raise oscerr.WrongArgs('Local directory is no package')
p = Package(".")
if command == "localrun" or command == "lr":
if command in ("localrun", "lr"):
mode = "local"
elif command == "manualrun" or command == "mr":
elif command in ("manualrun", "mr"):
mode = "manual"
elif command == "disabledrun" or command == "dr":
elif command in ("disabledrun", "dr"):
mode = "disabled"
elif command == "runall" or command == "ra":
elif command in ("runall", "ra"):
mode = "all"
return p.run_source_services(mode, singleservice)
@ -7796,7 +7796,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
new.extend(i)
results = new
headline = []
if kind == 'package' or kind == 'published/binary/id':
if kind in ('package', 'published/binary/id'):
headline = ['# Project', '# Package']
else:
headline = ['# Project']