diff --git a/tests/clitest.py b/tests/clitest.py index 2edc011ac..abdd9b921 100644 --- a/tests/clitest.py +++ b/tests/clitest.py @@ -156,13 +156,13 @@ class Command(object): exc = "" try: - if app.count("virt-install"): + if "virt-install" in app: ret = virtinstall.main(conn=conn) - elif app.count("virt-clone"): + elif "virt-clone" in app: ret = virtclone.main(conn=conn) - elif app.count("virt-convert"): + elif "virt-convert" in app: ret = virtconvert.main(conn=conn) - elif app.count("virt-xml"): + elif "virt-xml" in app: ret = virtxml.main(conn=conn) except SystemExit as sys_e: ret = sys_e.code @@ -316,13 +316,13 @@ class App(object): if iscompare and auto_printarg: if self.appname == "virt-install": - if (not cli.count("--print-xml") and - not cli.count("--print-step") and - not cli.count("--quiet")): + if ("--print-xml" not in cli and + "--print-step" not in cli and + "--quiet" not in cli): args += " --print-step all" elif self.appname == "virt-clone": - if not cli.count("--print-xml"): + if "--print-xml" not in cli: args += " --print-xml" return args diff --git a/tests/test_urls.py b/tests/test_urls.py index 3f595a53b..3864f776d 100644 --- a/tests/test_urls.py +++ b/tests/test_urls.py @@ -118,7 +118,7 @@ def _storeForDistro(fetcher, guest): try: return urlfetcher.getDistroStore(guest, fetcher) except Exception as e: - if str(e).count("502"): + if "502" in str(e): logging.debug("Caught proxy error: %s", str(e)) time.sleep(.5) continue diff --git a/virtinst/cli.py b/virtinst/cli.py index e001e02d3..2bcd88553 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -976,7 +976,7 @@ def parse_optstr_tuples(optstr): if not opt: continue - if opt.count("="): + if "=" in opt: cliname, val = opt.split("=", 1) else: cliname = opt diff --git a/virtinst/cloner.py b/virtinst/cloner.py index c4030ddfd..ede819db0 100644 --- a/virtinst/cloner.py +++ b/virtinst/cloner.py @@ -493,7 +493,7 @@ class Cloner(object): # If the suffix is greater than 7 characters, assume it isn't # a file extension and is part of the disk name, at which point # just stick '-clone' on the end. - if origpath.count(".") and len(origpath.rsplit(".", 1)[1]) <= 7: + if "." in origpath and len(origpath.rsplit(".", 1)[1]) <= 7: path, suffix = origpath.rsplit(".", 1) suffix = "." + suffix diff --git a/virtinst/device.py b/virtinst/device.py index 7118a1621..37d9364b8 100644 --- a/virtinst/device.py +++ b/virtinst/device.py @@ -59,12 +59,12 @@ class VirtualDeviceAddress(XMLBuilder): if addrstr is None: return - if addrstr.count(":") in [1, 2] and addrstr.count("."): + if addrstr.count(":") in [1, 2] and "." in addrstr: self.type = self.ADDRESS_TYPE_PCI addrstr, self.function = addrstr.split(".", 1) addrstr, self.slot = addrstr.rsplit(":", 1) self.domain = "0" - if addrstr.count(":"): + if ":" in addrstr: self.domain, self.bus = addrstr.split(":", 1) elif addrstr == "spapr-vio": self.type = self.ADDRESS_TYPE_SPAPR_VIO diff --git a/virtinst/hostkeymap.py b/virtinst/hostkeymap.py index 6ab474fbd..9f8360d0a 100644 --- a/virtinst/hostkeymap.py +++ b/virtinst/hostkeymap.py @@ -78,9 +78,9 @@ def _sysconfig_keyboard(f): re.search("KEYTABLE", s) is not None or (re.search("KEYBOARD", s) is not None and re.search("KEYBOARDTYPE", s) is None)): - if s.count('"'): + if '"' in s: delim = '"' - elif s.count('='): + elif '=' in s: delim = '=' else: continue diff --git a/virtinst/nodedev.py b/virtinst/nodedev.py index f29dda871..e3080d69b 100644 --- a/virtinst/nodedev.py +++ b/virtinst/nodedev.py @@ -345,11 +345,11 @@ def _AddressStringToHostdev(conn, addrstr): try: # Determine addrstr type - if addrstr.count(":") in [1, 2] and addrstr.count("."): + if addrstr.count(":") in [1, 2] and "." in addrstr: addrstr, func = addrstr.split(".", 1) addrstr, slot = addrstr.rsplit(":", 1) domain = "0" - if addrstr.count(":"): + if ":" in addrstr: domain, bus = addrstr.split(":", 1) else: bus = addrstr @@ -360,14 +360,14 @@ def _AddressStringToHostdev(conn, addrstr): hostdev.slot = "0x%.2X" % int(slot, 16) hostdev.bus = "0x%.2X" % int(bus, 16) - elif addrstr.count(":"): + elif ":" in addrstr: vendor, product = addrstr.split(":") hostdev.type = "usb" hostdev.vendor = "0x%.4X" % int(vendor, 16) hostdev.product = "0x%.4X" % int(product, 16) - elif addrstr.count("."): + elif "." in addrstr: bus, device = addrstr.split(".", 1) hostdev.type = "usb" diff --git a/virtinst/xmlbuilder.py b/virtinst/xmlbuilder.py index e79ad8308..2b5e3042f 100644 --- a/virtinst/xmlbuilder.py +++ b/virtinst/xmlbuilder.py @@ -93,7 +93,7 @@ def _sanitize_libxml_xml(xml): # Strip starting line if xml.startswith("