Blame SOURCES/0007-Python-3-compatible-string-operations.patch

1330ca
From 79136996ad2cf9d5ea51cc0a053cfe5815785c41 Mon Sep 17 00:00:00 2001
1330ca
From: Tomas Kasparek <tkasparek@redhat.com>
1330ca
Date: Mon, 5 Mar 2018 11:34:57 +0100
1330ca
Subject: [PATCH 07/17] Python 3 compatible string operations
1330ca
1330ca
---
1330ca
 koan/app.py      | 9 ++++-----
1330ca
 koan/register.py | 3 +--
1330ca
 koan/utils.py    | 7 +++----
1330ca
 3 files changed, 8 insertions(+), 11 deletions(-)
1330ca
1330ca
diff --git a/koan/app.py b/koan/app.py
1330ca
index c1d79c2..e727932 100755
1330ca
--- a/koan/app.py
1330ca
+++ b/koan/app.py
1330ca
@@ -40,7 +40,6 @@ try: #python2
1330ca
     import xmlrpclib
1330ca
 except ImportError: #python3
1330ca
     import xmlrpc.client as xmlrpclib
1330ca
-import string
1330ca
 import re
1330ca
 from . import utils
1330ca
 
1330ca
@@ -880,7 +879,7 @@ class Koan:
1330ca
                 cmd.append("--copy-default")
1330ca
 
1330ca
             boot_probe_ret_code, probe_output = self.get_boot_loader_info()
1330ca
-            if boot_probe_ret_code == 0 and string.find(probe_output, "lilo") >= 0:
1330ca
+            if boot_probe_ret_code == 0 and probe_output.find("lilo") >= 0:
1330ca
                 cmd.append("--lilo")
1330ca
 
1330ca
             if self.add_reinstall_entry:
1330ca
@@ -929,7 +928,7 @@ class Koan:
1330ca
             else:
1330ca
                 # if grubby --bootloader-probe returns lilo,
1330ca
                 #    apply lilo changes
1330ca
-                if boot_probe_ret_code == 0 and string.find(probe_output, "lilo") != -1:
1330ca
+                if boot_probe_ret_code == 0 and probe_output.find("lilo") != -1:
1330ca
                     print("- applying lilo changes")
1330ca
                     cmd = [ "/sbin/lilo" ]
1330ca
                     utils.subprocess_call(cmd)
1330ca
@@ -1132,10 +1131,10 @@ class Koan:
1330ca
            hash2 = utils.input_string_or_hash(self.kopts_override)
1330ca
            hashv.update(hash2)
1330ca
         options = utils.hash_to_string(hashv)
1330ca
-        options = string.replace(options, "lang ","lang= ")
1330ca
+        options = options.replace("lang ","lang= ")
1330ca
         # if using ksdevice=bootif that only works for PXE so replace
1330ca
         # it with something that will work
1330ca
-        options = string.replace(options, "ksdevice=bootif","ksdevice=link")
1330ca
+        options = options.replace("ksdevice=bootif","ksdevice=link")
1330ca
         return options
1330ca
 
1330ca
     #---------------------------------------------------
1330ca
diff --git a/koan/register.py b/koan/register.py
1330ca
index 5d28acd..a69f2d1 100755
1330ca
--- a/koan/register.py
1330ca
+++ b/koan/register.py
1330ca
@@ -31,7 +31,6 @@ except ImportError: #python3
1330ca
     import xmlrpc.client as xmlrpclib
1330ca
 import socket
1330ca
 from . import utils
1330ca
-import string
1330ca
 
1330ca
 # usage: cobbler-register [--server=server] [--hostname=hostname] --profile=foo
1330ca
 
1330ca
@@ -84,7 +83,7 @@ def main():
1330ca
         except:
1330ca
             print(xa)
1330ca
             print(xb)
1330ca
-            print(string.join(traceback.format_list(traceback.extract_tb(tb))))
1330ca
+            print("".join(traceback.format_list(traceback.extract_tb(tb))))
1330ca
         return 1
1330ca
 
1330ca
     return 0
1330ca
diff --git a/koan/utils.py b/koan/utils.py
1330ca
index 1aee405..f2f2692 100644
1330ca
--- a/koan/utils.py
1330ca
+++ b/koan/utils.py
1330ca
@@ -31,7 +31,6 @@ try: #python2
1330ca
 except ImportError: #python3
1330ca
     import urllib.request as urllib2
1330ca
     import xmlrpc.client as xmlrpclib
1330ca
-import string
1330ca
 import shutil
1330ca
 import tempfile
1330ca
 import urlgrabber
1330ca
@@ -181,9 +180,9 @@ def input_string_or_hash(options,delim=None,allow_multiples=True):
1330ca
         raise InfoException("No idea what to do with list: %s" % options)
1330ca
     elif type(options) == type(""):
1330ca
         new_dict = {}
1330ca
-        tokens = string.split(options, delim)
1330ca
+        tokens = options.split(delim)
1330ca
         for t in tokens:
1330ca
-            tokens2 = string.split(t,"=",1)
1330ca
+            tokens2 = t.split("=",1)
1330ca
             if len(tokens2) == 1:
1330ca
                 # this is a singleton option, no value
1330ca
                 key = tokens2[0]
1330ca
@@ -246,7 +245,7 @@ def nfsmount(input_path):
1330ca
     # FIXME: move this function to util.py so other modules can use it
1330ca
     # we have to mount it first
1330ca
     filename = input_path.split("/")[-1]
1330ca
-    dirpath = string.join(input_path.split("/")[:-1],"/")
1330ca
+    dirpath = "/".join(input_path.split("/")[:-1])
1330ca
     tempdir = tempfile.mkdtemp(suffix='.mnt', prefix='koan_', dir='/tmp')
1330ca
     mount_cmd = [
1330ca
          "/bin/mount", "-t", "nfs", "-o", "ro", dirpath, tempdir
1330ca
-- 
1330ca
2.5.5
1330ca