[libvirt] [PATCH v2] move format.py into src, cleanup module import code

Guannan Ren gren at redhat.com
Wed Apr 25 06:13:59 UTC 2012


On 04/25/2012 01:49 PM, Osier Yang wrote:
> On 2012年04月25日 12:45, Guannan Ren wrote:
>> ---
>>   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 ++++++------
>>   src/log_generator.py     |    2 +-
>>   src/parser.py            |    4 ++--
>>   src/proxy.py             |    2 +-
>>   10 files changed, 14 insertions(+), 22 deletions(-)
>>   rename {utils =>  src}/format.py (100%)
>>
>> 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
>> -
>>   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
>
> log.py is still in utils. So it should be
>
> from utils import log
>
>>
>>   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])
>> -
>> -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
>
> likewise
>
>> +import format
>>
>>   class FuncGen(object):
>>       """ To generate a callable testcase"""
>> diff --git a/src/log_generator.py b/src/log_generator.py
>> index a001ef2..be483d6 100644
>> --- a/src/log_generator.py
>> +++ b/src/log_generator.py
>> @@ -22,7 +22,7 @@ import copy
>>   from xml.dom import minidom
>>   from xml.dom.minidom import Document
>>
>> -from src import exception
>> +import exception
>>
>>   class LogGenerator(object):
>>       """ Generate and parser log xml file
>> diff --git a/src/parser.py b/src/parser.py
>> index 8a861fd..38f0424 100644
>> --- a/src/parser.py
>> +++ b/src/parser.py
>> @@ -23,8 +23,8 @@ import sys
>>   import copy
>>   import string
>>
>> -from src import exception
>> -from src import env_parser
>> +import exception
>> +import env_parser
>>
>>   class CaseFileParser(object):
>>       """ Parser the case configuration file to generate a data list.
>> diff --git a/src/proxy.py b/src/proxy.py
>> index fe50fff..4751b3b 100644
>> --- a/src/proxy.py
>> +++ b/src/proxy.py
>> @@ -20,7 +20,7 @@
>>   # The proxy examines the list of unique test cases, received from the
>>   # generator and import each test case from appropriate module 
>> directory.
>>
>> -from src import exception
>> +import exception
>>
>>   class Proxy(object):
>>       """ The Proxy class is used for getting function reference """
>
>
> ACK with the two nits fixed.
>
> Osier

       Thanks, pushed with these two issues fixed.

       Guannan Ren




More information about the libvir-list mailing list