From patchwork Sun Aug 2 23:58:15 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 38811 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n72NsuAq009565 for ; Sun, 2 Aug 2009 23:54:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753937AbZHBXyx (ORCPT ); Sun, 2 Aug 2009 19:54:53 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753933AbZHBXyx (ORCPT ); Sun, 2 Aug 2009 19:54:53 -0400 Received: from mx2.redhat.com ([66.187.237.31]:37217 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753869AbZHBXyv (ORCPT ); Sun, 2 Aug 2009 19:54:51 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n72Ns1bB016632; Sun, 2 Aug 2009 19:54:11 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n72NroQP022162; Sun, 2 Aug 2009 19:53:50 -0400 Received: from localhost.localdomain (dhcp-1-188.tlv.redhat.com [10.35.1.188]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n72Nre6M017975; Sun, 2 Aug 2009 19:53:49 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH 06/12] KVM test: minor style changes to kvm_config.py Date: Mon, 3 Aug 2009 02:58:15 +0300 Message-Id: <8a2d08b846334a5eb097c2f32348d0c04a6789fb.1249257056.git.mgoldish@redhat.com> In-Reply-To: <9d4ca96f1445db6df176825a494d6504a3bddeba.1249257056.git.mgoldish@redhat.com> References: <1249257501-19337-1-git-send-email-mgoldish@redhat.com> <7845d2fd228ec0232af10e48dbb29e1076a265d6.1249257056.git.mgoldish@redhat.com> <9ec0626f3ca8c20d08cfd2448dbf249632ed969a.1249257056.git.mgoldish@redhat.com> <30ddf2ae0b04eb29d55dcece97fd956b75563045.1249257056.git.mgoldish@redhat.com> <3e87b54663c4483d10912231945fc37741087b8f.1249257056.git.mgoldish@redhat.com> <9d4ca96f1445db6df176825a494d6504a3bddeba.1249257056.git.mgoldish@redhat.com> In-Reply-To: <7845d2fd228ec0232af10e48dbb29e1076a265d6.1249257056.git.mgoldish@redhat.com> References: <7845d2fd228ec0232af10e48dbb29e1076a265d6.1249257056.git.mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org - Fix indentation of a few lines. - Limit lines to 80 characters. - Use list comprehension in config.filter(). - Replace '== None' with 'is None'. Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_config.py | 34 ++++++++++++++++++---------------- 1 files changed, 18 insertions(+), 16 deletions(-) diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py index 7e8b1db..e478a55 100755 --- a/client/tests/kvm/kvm_config.py +++ b/client/tests/kvm/kvm_config.py @@ -83,8 +83,8 @@ class config: @param filter: A regular expression that defines the filter. @param dict: Dictionary that will be inspected. """ - filter = re.compile("(\\.|^)" + filter + "(\\.|$)") - return filter.search(dict["name"]) != None + filter = re.compile(r"(\.|^)" + filter + r"(\.|$)") + return bool(filter.search(dict["name"])) def filter(self, filter, list=None): @@ -94,13 +94,9 @@ class config: @param filter: A regular expression that will be used as a filter. @param list: A list of dictionaries that will be filtered. """ - if list == None: + if list is None: list = self.list - filtered_list = [] - for dict in list: - if self.match(filter, dict): - filtered_list.append(dict) - return filtered_list + return [dict for dict in list if self.match(filter, dict)] # Currently unused, will be removed if it remains unused @@ -111,7 +107,7 @@ class config: @param filter: A regular expression that will filter the list. @param list: List which we want to know the indexes that match a filter. """ - if list == None: + if list is None: list = self.list block_list = [] prev_match = False @@ -248,17 +244,22 @@ class config: temp_list.append(new_dict) if subvariants: - # If we're parsing 'subvariants', we need to modify the list first - self.__modify_list_subvariants(temp_list, name, dep_list, add_to_shortname) + # If we're parsing 'subvariants', first modify the list + self.__modify_list_subvariants(temp_list, name, dep_list, + add_to_shortname) temp_list = self.parse(file, temp_list, restricted=True, prev_indent=indent) else: - # If we're parsing 'variants', we need to parse first and then modify the list + # If we're parsing 'variants', parse before modifying the list if self.debug: - self.__debug_print(indented_line, "Entering variant '%s' (variant inherits %d dicts)" % (name, len(list))) + self.__debug_print(indented_line, + "Entering variant '%s' " + "(variant inherits %d dicts)" % + (name, len(list))) temp_list = self.parse(file, temp_list, restricted=False, prev_indent=indent) - self.__modify_list_variants(temp_list, name, dep_list, add_to_shortname) + self.__modify_list_variants(temp_list, name, dep_list, + add_to_shortname) new_list += temp_list @@ -401,7 +402,7 @@ class config: continue if self.debug and not restricted: self.__debug_print(indented_line, - "Entering file %s" % words[1]) + "Entering file %s" % words[1]) if self.filename: filename = os.path.join(os.path.dirname(self.filename), words[1]) @@ -440,7 +441,8 @@ class config: # Everything inside an exception should be parsed in # restricted mode new_list += self.parse(file, list[index:index+1], - restricted=True, prev_indent=indent) + restricted=True, + prev_indent=indent) else: new_list += list[index:index+1] list = new_list