Re: [test-API PATCH 1/4] filter: new class for filter or extract data

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

 



On 04/11/2012 04:04 PM, Guannan Ren wrote:
>     activityfilter.py
> ---
>  activityfilter.py |   74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 74 insertions(+), 0 deletions(-)
>  create mode 100644 activityfilter.py
> 
> diff --git a/activityfilter.py b/activityfilter.py
> new file mode 100644
> index 0000000..d99d690
> --- /dev/null
> +++ b/activityfilter.py
> @@ -0,0 +1,74 @@
> +#!/usr/bin/env python
> +#
> +# libvirt-test-API is copyright 2010, 2012 Red Hat, Inc.
> +#
> +# libvirt-test-API is free software: you can redistribute it and/or modify it
> +# under the terms of the GNU General Public License as published by
> +# the Free Software Foundation, either version 2 of the License, or
> +# (at your option) any later version. This program is distributed in
> +# the hope that it will be useful, but WITHOUT ANY WARRANTY; without
> +# even the implied warranties of TITLE, NON-INFRINGEMENT,
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> +#
> +# The GPL text is available in the file COPYING that accompanies this
> +# distribution and at <http://www.gnu.org/licenses>.
> +#
> +
> +
> +class Filter(object):
> +    """filter activity list to form various data list"""
> +    def __init__(self, activities_list):
> +        self.testcase_keys = []
> +        for activity in activities_list:
> +            for testcase in activity:
> +                testcases_key = testcase.keys()
> +                self.testcase_keys += testcases_key
> +
> +    def unique_testcase_cleansuffix(self):
> +        """get a list of module:testcase from activities_list
> +           eliminate duplicate items, with 'module:testcase_clean'
> +        """
> +        keylist_clean = self._keylist_cleanappended_without_sleep()
> +        return list(set(keylist_clean))
> +
> +    def unique_testcases(self):
> +        """ get a list of module:testcase from activities_list
> +            eliminate duplicate items
> +        """
> +        keylist = self._keylist_without_sleep_clean()
> +        return list(set(keylist))
> +
> +    def _keylist_without_sleep_clean(self):
> +        """ filter out 'clean' and 'sleep' flag
> +            to generate a list of testcases
> +        """
> +        keylist = []
> +        for key in self.testcase_keys:
> +            key = key.lower()
> +            if key == 'clean' or key == 'sleep':
> +                continue
> +
> +            keylist.append(key)
> +
> +        return keylist
> +
> +    def _keylist_cleanappended_without_sleep(self):
> +        """ remove 'sleep' flag, and append ':_clean' to
> +            the previous testcase to form a new element
> +        """
> +        keylist_clean = []
> +        prev_casename = ''
> +
> +        for key in self.testcase_keys:
> +            key = key.lower()
> +            if key == 'sleep':
> +                continue
> +
> +            if key == 'clean':
> +                keylist_clean.append(prev_casename + ":_clean")
> +                continue
> +
> +            prev_casename = key
> +            keylist_clean.append(prev_casename)
> +
> +        return keylist_clean

This looks ok, ACK.
I'm looking at the rest now.

Martin

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