Re: [test-API 03/17] Rename src/env_parser.py as src/global_parser.py

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

 



On 04/20/2012 08:46 AM, Osier Yang wrote:
> And:
> 
> % for i in $(grep 'envparser' * -r | awk -F':' '{print $1}' | uniq); do \
>     sed -i -e 's/envparser/global_parser/g' $i; \
>   done
> 
> % for i in $(grep 'Envparser' * -r | awk -F':' '{print $1}' | uniq); do \
>     sed -i -e 's/Envparser/GlobalParser/g' $i; \
>   done
> 
> % for i in $(grep 'env_parser' * -r | awk -F':' '{print $1}' | uniq); do \
>     sed -i -e 's/envparser/GlobalParser/g' $i; \
>   done
> 
> Typo fixes:
> 
> % for i in $(grep 'Envpaser' * -r | awk -F':' '{print $1}' | uniq); do \
>     sed -i -e 's/Envpaser/GlobalParser/g' $i; \
>   done
> ---
>  .../en-US/Understanding_libvirt-test-API.xml       |    2 +-
>  .../en-US/Writing_a_test_case.xml                  |   16 ++++++++--------
>  repos/domain/install_image.py                      |    6 +++---
>  repos/domain/install_linux_cdrom.py                |    8 ++++----
>  repos/domain/install_linux_check.py                |    6 +++---
>  repos/domain/install_linux_net.py                  |   12 ++++++------
>  repos/domain/install_windows_cdrom.py              |   12 ++++++------
>  .../multiple_thread_block_on_domain_create.py      |    8 ++++----
>  src/env_inspect.py                                 |   14 +++++++-------
>  src/generator.py                                   |    4 ++--
>  src/{env_parser.py => global_parser.py}            |    4 ++--
>  src/parser.py                                      |    4 ++--
>  12 files changed, 48 insertions(+), 48 deletions(-)
>  rename src/{env_parser.py => global_parser.py} (97%)
> 
> diff --git a/docs/User_Guide/libvirt-test-API_Guide/en-US/Understanding_libvirt-test-API.xml b/docs/User_Guide/libvirt-test-API_Guide/en-US/Understanding_libvirt-test-API.xml
> index 88c1b76..a563953 100644
> --- a/docs/User_Guide/libvirt-test-API_Guide/en-US/Understanding_libvirt-test-API.xml
> +++ b/docs/User_Guide/libvirt-test-API_Guide/en-US/Understanding_libvirt-test-API.xml
> @@ -206,7 +206,7 @@ repos
>            <para>Random MAC address generator. Useful when installing a guest machine.</para>
>          </listitem>
>          <listitem>
> -          <para><filename>env_parser.py</filename> is the parser component of the environment INI file.</para>
> +          <para><filename>global_parser.py</filename> is the parser component of the environment INI file.</para>
>          </listitem>
>          <listitem>
>            <para><filename>check.py</filename> verifies if a hypervisor is running.</para>
> diff --git a/docs/User_Guide/libvirt-test-API_Guide/en-US/Writing_a_test_case.xml b/docs/User_Guide/libvirt-test-API_Guide/en-US/Writing_a_test_case.xml
> index 2a74518..b36c660 100644
> --- a/docs/User_Guide/libvirt-test-API_Guide/en-US/Writing_a_test_case.xml
> +++ b/docs/User_Guide/libvirt-test-API_Guide/en-US/Writing_a_test_case.xml
> @@ -141,7 +141,7 @@ sys.path.append(rootdir)
>  import exception
>  from lib import connectAPI
>  from lib import storageAPI
> -from utils import env_parser
> +from utils import global_parser
>  from utils import xml_builder
>  
>  envfile = 'env.ini'
> @@ -149,9 +149,9 @@ envfile = 'env.ini'
>  def initialize_storage(dict):
>      logger = dict['logger']
>      dict['hypertype'] = 'xen'
> -    envparser = env_parser.Envpaser(envfile)
> -    dict['sourcename'] = envparser.get_value('storage', 'sourcename')
> -    dict['sourcepath'] = envparser.get_value('storage', 'sourcepath')
> +    global_parser = global_parser.GlobalParser(envfile)

This is a little misleading, before this line, global_parser is a class,
but after this line global_parser is a generated object of this class os
something? I'm not sure this improves readability. As I see it is done
in almost the whole patch. Do we really want it this way?
How about at least:

import utils
global_parser = utils.global_parser.GlobalParser(envfile)

We don't have to have from <module> import <class_or_whatever> everywhere =)

> +    dict['sourcename'] = global_parser.get_value('storage', 'sourcename')
> +    dict['sourcepath'] = global_parser.get_value('storage', 'sourcepath')
>  
>      logger.info('prepare create storage pool')
>      xmlobj = xml_builder.XmlBuilder()
> @@ -200,7 +200,7 @@ sys.path.append(rootdir)
>  import exception
>  from lib import connectAPI
>  from lib import domainAPI
> -from utils import env_parser
> +from utils import global_parser
>  from utils import xml_builder
>  
>  envfile = 'env.ini'
> @@ -237,9 +237,9 @@ def install_guest(dict):
>      dict['bootcd'] = '/tmp/%s/custom.iso' %gname
>  
>      logger.info('get system environment information')
> -    envparser = env_parser.Envpaser(envfile)
> -    url = envparser.get_value("guest", gname + "src")
> -    dict['kickstart'] = envparser.get_value("guest", gname + "ks")
> +    global_parser = global_parser.GlobalParser(envfile)
> +    url = global_parser.get_value("guest", gname + "src")
> +    dict['kickstart'] = global_parser.get_value("guest", gname + "ks")
>      logger.debug('install source: \n    %s' %url)
>      logger.debug('kisckstart file: \n    %s' %dict['kickstart'])
>  
<snip>
> diff --git a/src/parser.py b/src/parser.py
> index 8a861fd..46a28fd 100644
> --- a/src/parser.py
> +++ b/src/parser.py
> @@ -24,7 +24,7 @@ import copy
>  import string
>  
>  from src import exception
> -from src import env_parser
> +from src import global_parser
>  
>  class CaseFileParser(object):
>      """ Parser the case configuration file to generate a data list.
> @@ -35,7 +35,7 @@ class CaseFileParser(object):
>          self.missing_variables = []
>          self.debug = debug
>          self.casefile = casefile
> -        self.env = env_parser.Envparser("global.cfg")
> +        self.env = global_parser.GlobalParser("global.cfg")

in this case, the env = env_parser looks better, but even like this it
makes sense and it's ok, I guess.

>          self.loop_finish = False
>          self.loop_start = 0
>          self.loop_end = 0

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