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

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