Re: [test-API][PATCH 1/2] Fix compatibility problem on python 2.4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  ack

  The rpartition string methods family is from Python 2.5.

  Guannan Ren

----- Original Message -----
From: "Wayne Sun" <gsun@xxxxxxxxxx>
To: libvir-list@xxxxxxxxxx
Sent: Friday, January 20, 2012 1:34:13 PM
Subject:  [test-API][PATCH 1/2] Fix compatibility problem on python	2.4

  * switch rpartition with rsplit
  * adjust the style
---
 generator.py |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/generator.py b/generator.py
index 9a2ed06..6108963 100644
--- a/generator.py
+++ b/generator.py
@@ -124,10 +124,14 @@ class FuncGen(object):
         for i in range(loop_number):
 
             case_ref_name = self.cases_ref_names[i]
-            pkg_casename = case_ref_name.rpartition(":")[0]
-            funcname = case_ref_name.rpartition(":")[-1]
+            pkg_casename = case_ref_name.rsplit(":", 1)[0]
+            funcname = case_ref_name.rsplit(":", 1)[-1]
+
+            if "_clean" not in funcname:
+                cleanoper = 0
+            else:
+                cleanoper = 1
 
-            cleanoper = 0 if "_clean" not in funcname else 1
 
             if not cleanoper:
                 self.fmt.print_start(pkg_casename, env_logger)
@@ -182,7 +186,10 @@ class FuncGen(object):
                 if not cleanoper:
                     self.fmt.print_end(pkg_casename, ret, env_logger)
                 else:
-                    self.fmt.print_string(21*" " + "Done" if clean_ret < 1 else 21*" " + "Fail", env_logger)
+                    if clean_ret < 1:
+                        self.fmt.print_string(21*" " + "Done", env_logger)
+                    else:
+                        self.fmt.print_string(21*" " + "Fail", env_logger)
 
         end_time = time.strftime("%Y-%m-%d %H:%M:%S")
 
-- 
1.7.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]