Re: [PATCH] test-API: Remove trailing spaces

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

 



On 03/26/2012 03:28 PM, Osier Yang wrote:
Script used to do the work:

% for f in $(find . -type f -name "*.py"); do \
   sed -i -e "s/\(?*\)\s\+$/\1/g" $f; \
   done
---
  env_inspect.py                   |   20 +++++-----
  exception.py                     |   12 +++---
  lib/snapshotAPI.py               |   18 ++++----
  logxmlparser.py                  |   80 +++++++++++++++++++-------------------
  process.py                       |    6 +-
  repos/domain/attach_interface.py |    2 +-
  repos/domain/ownership_test.py   |    2 +-
  7 files changed, 70 insertions(+), 70 deletions(-)

diff --git a/env_inspect.py b/env_inspect.py
index e790e03..a290329 100644
--- a/env_inspect.py
+++ b/env_inspect.py
@@ -13,11 +13,11 @@
  # The GPL text is available in the file COPYING that accompanies this
  # distribution and at<http://www.gnu.org/licenses>.
  #
-# Filename: envinspect.py
-# Summary: To generate a callable class for clearing testing environment
-# Description: The module match the reference of clearing function
-#              from each testcase to the corresponding testcase's
-#              argument in the order of testcase running
+# Filename: envinspect.py
+# Summary: To generate a callable class for clearing testing environment
+# Description: The module match the reference of clearing function
+#              from each testcase to the corresponding testcase's
+#              argument in the order of testcase running

  import subprocess

@@ -72,7 +72,7 @@ class EnvInspect(object):
      """to check and collect the testing enviroment infomation
         before performing testing
      """
-
+
      def __init__(self, logger):
          self.logger = logger

@@ -87,7 +87,7 @@ class EnvInspect(object):
          self.logger.info("    %-36s%-6s" % (get_libvirt_ver()[1], result))

          if get_libvirt_pyth_ver()[0] == 100:
-            result = NOTOK
+            result = NOTOK
              flag = 1
          else:
              result = OK
@@ -100,7 +100,7 @@ class EnvInspect(object):
              result = OK
          self.logger.info("    %-36s%-6s" % (get_libvirt_cli_ver()[1], result))

-        if get_qemu_kvm_ver()[0] == 150 and flag == 0:
+        if get_qemu_kvm_ver()[0] == 150 and flag == 0:
              flag = 0
          elif get_qemu_kvm_ver()[0] == 150 and flag == 1:
              flag = 1
@@ -115,8 +115,8 @@ class EnvInspect(object):
              result = OK
          self.logger.info("    %-36s%-6s" % (get_kernel_ver()[1], result))

-        return flag
-
+        return flag
+

  OK = "ok"
  NOTOK = "not ok"
diff --git a/exception.py b/exception.py
index 1a6d6f1..5a6a6d3 100644
--- a/exception.py
+++ b/exception.py
@@ -13,10 +13,10 @@
  # The GPL text is available in the file COPYING that accompanies this
  # distribution and at<http://www.gnu.org/licenses>.
  #
-# Filename: exception.py
-# Summary: the exception class
-# Description: The module defines the exceptions the framework could use
-#              when fatal error occurred.
+# Filename: exception.py
+# Summary: the exception class
+# Description: The module defines the exceptions the framework could use
+#              when fatal error occurred.

  import libvirt

@@ -32,13 +32,13 @@ class LibvirtException(Exception):
          return repr(self.errorstr)

      def response(self):
-        self.status = {'code':self.code, 'message':"%s:%s" %
+        self.status = {'code':self.code, 'message':"%s:%s" %
                         (self.message, str(self))}
          return self.status

  class FileDoesNotExist(LibvirtException):
      code = 201
-    message = "File does not exist"
+    message = "File does not exist"

  class SectionDoesNotExist(LibvirtException):
      code = 202
diff --git a/lib/snapshotAPI.py b/lib/snapshotAPI.py
index 43ccb89..d363992 100644
--- a/lib/snapshotAPI.py
+++ b/lib/snapshotAPI.py
@@ -24,14 +24,14 @@ import libvirt
  import re
  import os

-def append_path(path):
+def append_path(path):
      """Append root path of package"""
      if path in sys.path:
          pass
      else:
          sys.path.append(path)
-
-pwd = os.getcwd()
+
+pwd = os.getcwd()
  result = re.search('(.*)libvirt-test-API', pwd)
  append_path(result.group(0))

@@ -39,7 +39,7 @@ import exception

  class SnapshotAPI(object):
      def __init__(self, connection):
-        self.conn = connection
+        self.conn = connection

      def create(self, domname, xml_desc, flag = 0):
  	try:
@@ -57,7 +57,7 @@ class SnapshotAPI(object):
          except libvirt.libvirtError, e:
              message = e.get_error_message()
              code = e.get_error_code()
-            raise exception.LibvirtAPI(message, code)
+            raise exception.LibvirtAPI(message, code)

      def snapshot_name_list(self, domname, flag = 0):
          try:
@@ -66,7 +66,7 @@ class SnapshotAPI(object):
          except libvirt.libvirtError, e:
              message = e.get_error_message()
              code = e.get_error_code()
-            raise exception.LibvirtAPI(message, code)
+            raise exception.LibvirtAPI(message, code)

      def snapshot_nums(self, domname, flag = 0):
          try:
@@ -95,7 +95,7 @@ class SnapshotAPI(object):
              message = e.get_error_message()
              code = e.get_error_code()
              raise exception.LibvirtAPI(message, code)
-
+
      def delete(self, domname, snapname, flag = 0):
          try:
              snap = self.snapshot_lookup_by_name(domname, snapname, flag = 0)
@@ -103,7 +103,7 @@ class SnapshotAPI(object):
          except libvirt.libvirtError, e:
              message = e.get_error_message()
              code = e.get_error_code()
-            raise exception.LibvirtAPI(message, code)
+            raise exception.LibvirtAPI(message, code)

      def get_xml_desc(self, domname, snapname, flag = 0):
          try:
@@ -122,4 +122,4 @@ class SnapshotAPI(object):
              message = e.get_error_message()
              code = e.get_error_code()
              raise exception.LibvirtAPI(message, code)
-
+
diff --git a/logxmlparser.py b/logxmlparser.py
index 014397e..48e3c51 100644
--- a/logxmlparser.py
+++ b/logxmlparser.py
@@ -13,10 +13,10 @@
  # The GPL text is available in the file COPYING that accompanies this
  # distribution and at<http://www.gnu.org/licenses>.
  #
-# Filename: xmlparser.py
-# Summary: generate xmlfile for log management
-# Description: The module gives methods to write xml block
-#              during a testrun running
+# Filename: xmlparser.py
+# Summary: generate xmlfile for log management
+# Description: The module gives methods to write xml block
+#              during a testrun running

  import os
  import copy
@@ -30,19 +30,19 @@ class LogXMLParser(object):
      """
      def __init__(self, logxml):
          self.logxml = logxml
-        self.doc = Document()
+        self.doc = Document()

-    def generate_logxml(self):
+    def generate_logxml(self):
          """ generate a new log xml file with head if that doesn't exist """
          XMLFILE = open(self.logxml, "w")
          XMLFILE.write('<?xml version="1.0"?><?xml-stylesheet type="text/xsl"\
                           href="log.xsl"?><log xmlns:xlink= \
-                         "http://www.w3.org/1999/xlink";></log>')
-        XMLFILE.close()
+                         "http://www.w3.org/1999/xlink";></log>')
+        XMLFILE.close()

      def add_testrun_xml(self, testrunid):
          """ add testrun info into log xml file"""
-        xmldoc = minidom.parse(self.logxml)
+        xmldoc = minidom.parse(self.logxml)
          testrun = self.doc.createElement('testrun')
          testrun.setAttribute("name", testrunid)
          xmldoc.childNodes[1].appendChild(testrun)
@@ -52,30 +52,30 @@ class LogXMLParser(object):
      def add_test_xml(self, testrunid, testid):
          """ add a test info into log xml file"""
          xmldoc = minidom.parse(self.logxml)
-        test = self.doc.createElement('test')
+        test = self.doc.createElement('test')
          test.setAttribute("id", testid)
          testrunlist = xmldoc.getElementsByTagName('testrun')
          for testrun in testrunlist:
              runattr = testrun.attributes["name"]
              if runattr.value == testrunid:
-                testrun.appendChild(test)
+                testrun.appendChild(test)

-        self.__write_to_file(xmldoc, self.logxml)
+        self.__write_to_file(xmldoc, self.logxml)

      def add_testprocedure_xml(self, testrunid, testid, test_procedure):
          """ add test procedure info into log xml file """
          xmldoc = minidom.parse(self.logxml)

          procedure = self.doc.createElement('test_procedure')
-        casename = test_procedure.keys()[0]
+        casename = test_procedure.keys()[0]
          valuedict = test_procedure[casename]

          test_casename = self.doc.createElement('action')
-        test_casename.setAttribute('name', casename)
+        test_casename.setAttribute('name', casename)

          for arg in valuedict.keys():
-            test_arg = self.doc.createElement('arg')
-            test_arg.setAttribute("name", arg)
+            test_arg = self.doc.createElement('arg')
+            test_arg.setAttribute("name", arg)
              test_value = self.doc.createTextNode(valuedict[arg])
              test_arg.appendChild(test_value)
              test_casename.appendChild(test_arg)
@@ -92,20 +92,20 @@ class LogXMLParser(object):
                      if testattr.value == testid:
                          test.appendChild(procedure)

-        self. __write_to_file(xmldoc, self.logxml)
+        self. __write_to_file(xmldoc, self.logxml)

-    def add_test_summary(self, testrunid, testid, result,
+    def add_test_summary(self, testrunid, testid, result,
                           start_time, end_time, path):
          """ add a test summary xml block into log xml file """
          xmldoc = minidom.parse(self.logxml)
          testresult = self.doc.createElement('result')
          resulttext = self.doc.createTextNode(result)
          testresult.appendChild(resulttext)
-
+
          teststarttime = self.doc.createElement('start_time')
          starttimetext = self.doc.createTextNode(start_time)
          teststarttime.appendChild(starttimetext)
-
+
          testendtime = self.doc.createElement('end_time')
          endtimetext = self.doc.createTextNode(end_time)
          testendtime.appendChild(endtimetext)
@@ -126,20 +126,20 @@ class LogXMLParser(object):
                          test.childNodes.insert(0, testpath)
                          test.childNodes.insert(0, testendtime)
                          test.childNodes.insert(0, teststarttime)
-                        test.childNodes.insert(0, testresult)
+                        test.childNodes.insert(0, testresult)

          self. __write_to_file(xmldoc, self.logxml)


-    def add_testrun_summary(self, testrunid, passnum, failnum, totalnum,
+    def add_testrun_summary(self, testrunid, passnum, failnum, totalnum,
                              start_time, end_time):
          """ add a testrun summary xml block into log xml file """
          xmldoc = minidom.parse(self.logxml)
          testpass = self.doc.createElement('pass')
          passtext = self.doc.createTextNode(str(passnum))
          testpass.appendChild(passtext)
-
-        testfail = self.doc.createElement('fail')
+
+        testfail = self.doc.createElement('fail')
          failtext = self.doc.createTextNode(str(failnum))
          testfail.appendChild(failtext)

@@ -154,7 +154,7 @@ class LogXMLParser(object):
          teststarttime = self.doc.createElement('start_time')
          starttimetext = self.doc.createTextNode(start_time)
          teststarttime.appendChild(starttimetext)
-
+
          testendtime = self.doc.createElement('end_time')
          endtimetext = self.doc.createTextNode(end_time)
          testendtime.appendChild(endtimetext)
@@ -170,10 +170,10 @@ class LogXMLParser(object):
                  testrun.childNodes.insert(0, testpass)

          self. __write_to_file(xmldoc, self.logxml)
-
+
      def remove_test_xml(self, testrunid, testid):
          """ to remove a test xml block from a log xml file """
-        xmldoc = minidom.parse(self.logxml)
+        xmldoc = minidom.parse(self.logxml)
          testrunlist = xmldoc.getElementsByTagName('testrun')
          testrunattrlist = []

@@ -187,21 +187,21 @@ class LogXMLParser(object):
                      testattr = test.attributes["id"]
                      if testattr.value == testid:
                          testattrlist.append(testattr.value)
-                        testrun.removeChild(test)
+                        testrun.removeChild(test)
                  if len(testattrlist) == 0:
                      raise exception.NoTestFound(
-                        "In the xmllog file testrunid %s no testid %s found" %
+                        "In the xmllog file testrunid %s no testid %s found" %
                          (testrunid, testid))
          if len(testrunattrlist) == 0:
              raise exception.NoTestRunFound(
-                      "In the xmllog file no testrunid %s found" %
+                      "In the xmllog file no testrunid %s found" %
                         testrunid)

-        self. __write_to_file(xmldoc, self.logxml)
-
+        self. __write_to_file(xmldoc, self.logxml)
+
      def remove_testrun_xml(self, testrunid):
          """ remove a testrun xml block from log xml file """
-        xmldoc = minidom.parse(self.logxml)
+        xmldoc = minidom.parse(self.logxml)
          testrunlist = xmldoc.getElementsByTagName('testrun')
          testrunattrlist = []

@@ -213,9 +213,9 @@ class LogXMLParser(object):

          if len(testrunattrlist) == 0:
              raise exception.NoTestRunFound(
-                      "In the xmllog file no testrunid %s found" %
+                      "In the xmllog file no testrunid %s found" %
                        testrunid)
-
+
          self. __write_to_file(xmldoc, self.logxml)

      def remove_alltestrun_xml(self):
@@ -228,8 +228,8 @@ class LogXMLParser(object):
              runattr = testrun.attributes["name"]
              testrunattrlist.append(runattr.value)
              xmldoc.childNodes[1].removeChild(testrun)
-
-        self. __write_to_file(xmldoc, self.logxml)
+
+        self. __write_to_file(xmldoc, self.logxml)
          return testrunattrlist

      def merge_xmlfiles(self, logxml_two):
@@ -241,13 +241,13 @@ class LogXMLParser(object):

          for testrun in testrunlist_two_copy:
              xmldoc_one.childNodes[1].appendChild(testrun)
-
-        self. __write_to_file(xmldoc_one, self.logxml)
+
+        self. __write_to_file(xmldoc_one, self.logxml)
          self. __write_to_file(xmldoc_two, logxml_two)

      def __write_to_file(self, xmldoc, logxml):
          """ save changes into log xml file """
          file = open(logxml, "w")
-        xmldoc.writexml(file)
+        xmldoc.writexml(file)
          file.close()

diff --git a/process.py b/process.py
index 4d65f72..a712816 100644
--- a/process.py
+++ b/process.py
@@ -13,10 +13,10 @@
  # The GPL text is available in the file COPYING that accompanies this
  # distribution and at<http://www.gnu.org/licenses>.
  #
-# Filename: process.py
-# Summary: multiprocessing module
+# Filename: process.py
+# Summary: multiprocessing module
  # Description: If the switch of multiprocessing is on,
-#              the module will be called to fork subprocess
+#              the module will be called to fork subprocess

  import os
  import sys
diff --git a/repos/domain/attach_interface.py b/repos/domain/attach_interface.py
index 9d475a3..e6bbbda 100644
--- a/repos/domain/attach_interface.py
+++ b/repos/domain/attach_interface.py
@@ -107,7 +107,7 @@ def attach_interface(params):
              return 1
      finally:
          conn.close()
-        logger.info("closed hypervisor connection")
+        logger.info("closed hypervisor connection")

      if test_result:
          return 0
diff --git a/repos/domain/ownership_test.py b/repos/domain/ownership_test.py
index 1eacbcf..5464d86 100644
--- a/repos/domain/ownership_test.py
+++ b/repos/domain/ownership_test.py
@@ -230,7 +230,7 @@ def ownership_test(params):
      logger.info("check the domain state")
      ret = check_domain_running(domobj, guestname, logger)
      if ret:
-        return return_close(conn, logger, 1)
+        return return_close(conn, logger, 1)

      try:
          domobj.save(guestname, SAVE_FILE)

      Thanks and pushed

      Guannan Ren

--
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]