|
|
1330ca |
From 769722facf088ea59ab010b363fc44d18b70d670 Mon Sep 17 00:00:00 2001
|
|
|
1330ca |
From: Tomas Kasparek <tkasparek@redhat.com>
|
|
|
1330ca |
Date: Mon, 5 Mar 2018 11:43:20 +0100
|
|
|
1330ca |
Subject: [PATCH 14/17] has_key is not in Python 3
|
|
|
1330ca |
|
|
|
1330ca |
---
|
|
|
1330ca |
koan/app.py | 14 +++++++-------
|
|
|
1330ca |
koan/utils.py | 2 +-
|
|
|
1330ca |
koan/virtinstall.py | 4 ++--
|
|
|
1330ca |
koan/vmwcreate.py | 4 ++--
|
|
|
1330ca |
4 files changed, 12 insertions(+), 12 deletions(-)
|
|
|
1330ca |
|
|
|
1330ca |
diff --git a/koan/app.py b/koan/app.py
|
|
|
1330ca |
index f251c77..4ae4c90 100755
|
|
|
1330ca |
--- a/koan/app.py
|
|
|
1330ca |
+++ b/koan/app.py
|
|
|
1330ca |
@@ -454,9 +454,9 @@ class Koan:
|
|
|
1330ca |
#---------------------------------------------------
|
|
|
1330ca |
|
|
|
1330ca |
def safe_load(self,hashv,primary_key,alternate_key=None,default=None):
|
|
|
1330ca |
- if hashv.has_key(primary_key):
|
|
|
1330ca |
+ if primary_key in hashv:
|
|
|
1330ca |
return hashv[primary_key]
|
|
|
1330ca |
- elif alternate_key is not None and hashv.has_key(alternate_key):
|
|
|
1330ca |
+ elif alternate_key is not None and alternate_key in hashv:
|
|
|
1330ca |
return hashv[alternate_key]
|
|
|
1330ca |
else:
|
|
|
1330ca |
return default
|
|
|
1330ca |
@@ -524,7 +524,7 @@ class Koan:
|
|
|
1330ca |
if profile_data.get("xml_file","") != "":
|
|
|
1330ca |
raise InfoException("xmlfile based installations are not supported")
|
|
|
1330ca |
|
|
|
1330ca |
- elif profile_data.has_key("file"):
|
|
|
1330ca |
+ elif "file" in profile_data:
|
|
|
1330ca |
print("- ISO or Image based installation, always uses --virt-type=qemu")
|
|
|
1330ca |
self.virt_type = "qemu"
|
|
|
1330ca |
|
|
|
1330ca |
@@ -661,7 +661,7 @@ class Koan:
|
|
|
1330ca |
raise InfoException("koan does not know how to list that")
|
|
|
1330ca |
data = self.get_data(what)
|
|
|
1330ca |
for x in data:
|
|
|
1330ca |
- if x.has_key("name"):
|
|
|
1330ca |
+ if "name" in x:
|
|
|
1330ca |
print(x["name"])
|
|
|
1330ca |
return True
|
|
|
1330ca |
|
|
|
1330ca |
@@ -670,7 +670,7 @@ class Koan:
|
|
|
1330ca |
def display(self):
|
|
|
1330ca |
def after_download(self, profile_data):
|
|
|
1330ca |
for x in DISPLAY_PARAMS:
|
|
|
1330ca |
- if profile_data.has_key(x):
|
|
|
1330ca |
+ if x in profile_data:
|
|
|
1330ca |
value = profile_data[x]
|
|
|
1330ca |
if x == 'kernel_options':
|
|
|
1330ca |
value = self.calc_kernel_args(profile_data)
|
|
|
1330ca |
@@ -732,7 +732,7 @@ class Koan:
|
|
|
1330ca |
print("- file: %s" % save_as)
|
|
|
1330ca |
|
|
|
1330ca |
pattern = "http://%s/cblr/svc/op/template/%s/%s/path/%s"
|
|
|
1330ca |
- if profile_data.has_key("interfaces"):
|
|
|
1330ca |
+ if "interfaces" in profile_data:
|
|
|
1330ca |
url = pattern % (profile_data["http_server"],"system",profile_data["name"],dest)
|
|
|
1330ca |
else:
|
|
|
1330ca |
url = pattern % (profile_data["http_server"],"profile",profile_data["name"],dest)
|
|
|
1330ca |
@@ -1284,7 +1284,7 @@ class Koan:
|
|
|
1330ca |
if self.virt_name is not None:
|
|
|
1330ca |
# explicit override
|
|
|
1330ca |
name = self.virt_name
|
|
|
1330ca |
- elif profile_data.has_key("interfaces"):
|
|
|
1330ca |
+ elif "interfaces" in profile_data:
|
|
|
1330ca |
# this is a system object, just use the name
|
|
|
1330ca |
name = profile_data["name"]
|
|
|
1330ca |
else:
|
|
|
1330ca |
diff --git a/koan/utils.py b/koan/utils.py
|
|
|
1330ca |
index 0cd48ea..12ec718 100644
|
|
|
1330ca |
--- a/koan/utils.py
|
|
|
1330ca |
+++ b/koan/utils.py
|
|
|
1330ca |
@@ -206,7 +206,7 @@ def input_string_or_hash(options,delim=None,allow_multiples=True):
|
|
|
1330ca |
new_dict[key] = value
|
|
|
1330ca |
|
|
|
1330ca |
# dict.pop is not avail in 2.2
|
|
|
1330ca |
- if new_dict.has_key(""):
|
|
|
1330ca |
+ if "" in new_dict:
|
|
|
1330ca |
del new_dict[""]
|
|
|
1330ca |
return new_dict
|
|
|
1330ca |
elif type(options) == type({}):
|
|
|
1330ca |
diff --git a/koan/virtinstall.py b/koan/virtinstall.py
|
|
|
1330ca |
index 2d1f3df..5359b2a 100644
|
|
|
1330ca |
--- a/koan/virtinstall.py
|
|
|
1330ca |
+++ b/koan/virtinstall.py
|
|
|
1330ca |
@@ -233,7 +233,7 @@ def build_commandline(uri,
|
|
|
1330ca |
raise koan.InfoException("Profile 'file' required for image "
|
|
|
1330ca |
"install")
|
|
|
1330ca |
|
|
|
1330ca |
- elif profile_data.has_key("file"):
|
|
|
1330ca |
+ elif "file" in profile_data:
|
|
|
1330ca |
if is_xen:
|
|
|
1330ca |
raise koan.InfoException("Xen does not work with --image yet")
|
|
|
1330ca |
|
|
|
1330ca |
@@ -255,7 +255,7 @@ def build_commandline(uri,
|
|
|
1330ca |
floppy = utils.make_floppy(kickstart)
|
|
|
1330ca |
elif is_qemu or is_xen:
|
|
|
1330ca |
# images don't need to source this
|
|
|
1330ca |
- if not profile_data.has_key("install_tree"):
|
|
|
1330ca |
+ if not "install_tree" in profile_data:
|
|
|
1330ca |
raise koan.InfoException("Cannot find install source in kickstart file, aborting.")
|
|
|
1330ca |
|
|
|
1330ca |
if not profile_data["install_tree"].endswith("/"):
|
|
|
1330ca |
diff --git a/koan/vmwcreate.py b/koan/vmwcreate.py
|
|
|
1330ca |
index 82bfa4a..33c5819 100755
|
|
|
1330ca |
--- a/koan/vmwcreate.py
|
|
|
1330ca |
+++ b/koan/vmwcreate.py
|
|
|
1330ca |
@@ -126,11 +126,11 @@ def start_install(name=None,
|
|
|
1330ca |
virt_type=None,
|
|
|
1330ca |
virt_auto_boot=False):
|
|
|
1330ca |
|
|
|
1330ca |
- if profile_data.has_key("file"):
|
|
|
1330ca |
+ if "file" in profile_data:
|
|
|
1330ca |
raise koan.InfoException("vmware does not work with --image yet")
|
|
|
1330ca |
|
|
|
1330ca |
mac = None
|
|
|
1330ca |
- if not profile_data.has_key("interfaces"):
|
|
|
1330ca |
+ if not "interfaces" in profile_data:
|
|
|
1330ca |
print("- vmware installation requires a system, not a profile")
|
|
|
1330ca |
return 1
|
|
|
1330ca |
for iname in profile_data["interfaces"]:
|
|
|
1330ca |
--
|
|
|
1330ca |
2.5.5
|
|
|
1330ca |
|