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

Re: [libvirt] [test-API PATCH] move log.py and format.py into src, cleanup module import code



On 04/25/2012 11:48 AM, Osier Yang wrote:
On 2012年04月24日 13:17, Guannan Ren wrote:

Several different changes. Having explaination is better.

---
  libvirt-test-api         |    2 +-
  src/casecfgcheck.py      |    2 --
  src/env_clear.py         |    4 ++--
  src/env_inspect.py       |    2 +-
  src/env_parser.py        |    6 +-----
  src/exception.py         |    2 --
  {utils =>  src}/format.py |    0
  src/generator.py         |   12 ++++++------
  {utils =>  src}/log.py    |    0
  src/log.xsl              |    2 +-
  src/log_generator.py     |    2 +-
  src/parser.py            |    4 ++--
  src/proxy.py             |    2 +-
  13 files changed, 16 insertions(+), 24 deletions(-)
  rename {utils =>  src}/format.py (100%)
  rename {utils =>  src}/log.py (100%)

diff --git a/libvirt-test-api b/libvirt-test-api
index cec7679..4c8d515 100755
--- a/libvirt-test-api
+++ b/libvirt-test-api
@@ -27,7 +27,7 @@ from src import proxy
  from src import generator
  from src import env_clear
  from src import process
-from utils import log
+from src import log

NACK for this change. I think it's fine to move "format.py"
into src. but "log.py" should be in utils. It can be used
by utils too in future.


      it's ok for me,  currently the log.py is only used by generator.py




  from src.log_generator import LogGenerator
  from src.activityfilter import Filter
  from src.casecfgcheck import CaseCfgCheck
diff --git a/src/casecfgcheck.py b/src/casecfgcheck.py
index 252f4a4..755b03f 100644
--- a/src/casecfgcheck.py
+++ b/src/casecfgcheck.py
@@ -15,8 +15,6 @@
  # You should have received a copy of the GNU General Public License
  # along with this program. If not, see<http://www.gnu.org/licenses/>.

-from src import proxy

Looks fine.

-
  class CaseCfgCheck(object):
      """validate the options in testcase config file"""
      def __init__(self, proxy_obj, activities_list):
diff --git a/src/env_clear.py b/src/env_clear.py
index a4a8a8e..fa3b62c 100644
--- a/src/env_clear.py
+++ b/src/env_clear.py
@@ -18,8 +18,8 @@
# This module matches the reference of clearing function from each testcase # to the corresponding testcase's argument in the order of testcase running

-from src import mapper
-from utils import log
+import mapper
+import log

Does it still work well with these changes?

        yes,  this files are in the same folder, so import them directly.






  class EnvClear(object):
      """ Generate a callable class of executing clearing function in
diff --git a/src/env_inspect.py b/src/env_inspect.py
index 4942b33..b260ff8 100644
--- a/src/env_inspect.py
+++ b/src/env_inspect.py
@@ -19,7 +19,7 @@

  import commands
  import libvirt
-from src import sharedmod
+import sharedmod

  def check_libvirt(logger):
      virsh = 'virsh -v'
diff --git a/src/env_parser.py b/src/env_parser.py
index cf4168f..f02af57 100644
--- a/src/env_parser.py
+++ b/src/env_parser.py
@@ -21,11 +21,7 @@ import ConfigParser
  import os
  import sys

-dir = os.path.dirname(sys.modules[__name__].__file__)
-absdir = os.path.abspath(dir)
-sys.path.append(os.path.split(absdir)[0])
-

Why it's not neccessary anymore?

        the env_parser.py could use "."(the current directory)
        to import exception, it is redundant to append
        the absolute path of "."




-from src import exception
+import exception

  class Envparser(object):
      def __init__(self, configfile):
diff --git a/src/exception.py b/src/exception.py
index 9b61bac..70d0175 100644
--- a/src/exception.py
+++ b/src/exception.py
@@ -17,8 +17,6 @@
  # You should have received a copy of the GNU General Public License
  # along with this program. If not, see<http://www.gnu.org/licenses/>.

-import libvirt
-
  class LibvirtException(Exception):
      code = 200
      message = "General libvirt-test-suite Exception"
diff --git a/utils/format.py b/src/format.py
similarity index 100%
rename from utils/format.py
rename to src/format.py
diff --git a/src/generator.py b/src/generator.py
index 5b9a0a2..d4b0388 100644
--- a/src/generator.py
+++ b/src/generator.py
@@ -24,12 +24,12 @@ import sys
  import os
  import traceback

-from src import mapper
-from src.testcasexml import xml_file_to_str
-from src import env_parser
-from src import env_inspect
-from utils import log
-from utils import format
+import mapper
+from testcasexml import xml_file_to_str
+import env_parser
+import env_inspect
+import log
+import format

  class FuncGen(object):
      """ To generate a callable testcase"""
diff --git a/utils/log.py b/src/log.py
similarity index 100%
rename from utils/log.py
rename to src/log.py
diff --git a/src/log.xsl b/src/log.xsl
index 577a0a5..589a720 100644
--- a/src/log.xsl
+++ b/src/log.xsl
@@ -5,7 +5,7 @@
<html>
<head>
<title>Libvirt testing log</title>
-<link rel="stylesheet" href="src/log.css" type="text/css" media="screen" />
+<link rel="stylesheet" href="log.css" type="text/css" media="screen" />

Is it correct change? does the log.xml can't be displayed well in
browser after the change? "src/log.css" worked for me fine when I
made the change.

         Agree,  keep it.



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