Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id BC083E00D62; Fri, 9 Dec 2016 08:29:57 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no * trust * [209.85.210.173 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily * valid * -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Received: from mail-wj0-f173.google.com (mail-wj0-f173.google.com [209.85.210.173]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 1F75BE00D40 for ; Fri, 9 Dec 2016 08:29:55 -0800 (PST) Received: by mail-wj0-f173.google.com with SMTP id xy5so18904801wjc.0 for ; Fri, 09 Dec 2016 08:29:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PALjtc5BFWm9dgzzhMrxIEabT79F4ohEVNJnJ8IPyG0=; b=rtwiQvyDHafBy5fbpd7aIuFJWuHfroZ6q5GMFR9IKVFxou3XYo1L3gp9lz/zrlI76j MBuf0g7MFVwGk83y8cW7evq4jmJKc7BA2FipsAinb9YCQwCPPsQ6/WNaItXOnjnEwCTw oamBLkQ/xU0rjLm0jy6lPT7No5Vo1VCp6caKwTp8TzcVo7hLwPwq6GuKWa3vingMtaZ6 30zOT25YvjEPK8eGpTLrvBLG4Ch0iXMM89JWkg9feFZKkMGxpVg8S+1Uovl8oRQ2CBUA WPM9NjddNrc2mubgS2B9V8POtQnbeRhOo8uSq/ZQVJZtDvYlMmbDrA1/FkSvQvxbVc3G bnQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PALjtc5BFWm9dgzzhMrxIEabT79F4ohEVNJnJ8IPyG0=; b=Qe1KM4UKSQqKOK7TXitEloM9hCcBHV7yyWA9zXgfnvaGoLuJoWk5S8OW8wkhSHb32Y b0QvUycXZ3swjTyQHQUcOC2oll7KLxtfv1ga8ukcCE2QJNy3JFKJrhba5uuTZHQLoZhk bWepQ6ZteRMWYSPpIgLyA6RS6iPZBDs8B7LnNDdJxacDFuR7V5E0+ynO0KmuRx8VxNQT cccvPeAuTNbNUZxNnfLIRi07bl9i9omFAFl3YpUBu04gSGheQCSe/bqIlYhJ3HVqyVYZ 7WUzwVZEtyKmftPw/k0WbfpvfXZeqSMekpzjxV+LWv2OiTA4KI7QQc34rTokyWrnKxuk Ojlg== X-Gm-Message-State: AKaTC03XuE52F+HJorwnS6qQXZKKCNrLm5NGtsu4Ir4rk/t6dnXEWS6UvJW2PwAXUWkIhgR3 X-Received: by 10.194.59.71 with SMTP id x7mr82146382wjq.74.1481300994749; Fri, 09 Dec 2016 08:29:54 -0800 (PST) Received: from localhost.localdomain ([192.198.151.62]) by smtp.gmail.com with ESMTPSA id x5sm43051348wje.36.2016.12.09.08.29.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Dec 2016 08:29:54 -0800 (PST) From: Michael Wood To: toaster@yoctoproject.org Date: Fri, 9 Dec 2016 16:29:38 +0000 Message-Id: <1481300985-7356-8-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481300985-7356-1-git-send-email-michael.g.wood@intel.com> References: <1481300985-7356-1-git-send-email-michael.g.wood@intel.com> Subject: [PATCH 07/14] toaster: typeaheads widgets Fix flake8 issues and remove redundant code X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Dec 2016 16:29:57 -0000 Fix flake8 issues and remove redundant __init__ function definitions from typeaheads (likely a copy and paste error). Signed-off-by: Michael Wood --- bitbake/lib/toaster/toastergui/typeaheads.py | 80 ++++++++++++++-------------- bitbake/lib/toaster/toastergui/widgets.py | 8 +-- 2 files changed, 45 insertions(+), 43 deletions(-) diff --git a/bitbake/lib/toaster/toastergui/typeaheads.py b/bitbake/lib/toaster/toastergui/typeaheads.py index 4ded9ac..2c6c145 100644 --- a/bitbake/lib/toaster/toastergui/typeaheads.py +++ b/bitbake/lib/toaster/toastergui/typeaheads.py @@ -23,8 +23,6 @@ from django.core.urlresolvers import reverse class LayersTypeAhead(ToasterTypeAhead): """ Typeahead for layers available and not added in the current project's configuration """ - def __init__(self): - super(LayersTypeAhead, self).__init__() def apply_search(self, search_term, prj, request): layers = prj.get_all_compatible_layer_versions() @@ -33,13 +31,15 @@ class LayersTypeAhead(ToasterTypeAhead): # Unlike the other typeaheads we also don't want to show suggestions # for layers already in the project unless required such as when adding # layerdeps to a new layer. - if ("include_added" in request.GET and - request.GET['include_added'] != "true"): + if "include_added" in request.GET and \ + request.GET['include_added'] != "true": layers = layers.exclude( pk__in=prj.get_project_layer_versions(pk=True)) primary_results = layers.filter(layer__name__istartswith=search_term) - secondary_results = layers.filter(layer__name__icontains=search_term).exclude(pk__in=primary_results) + secondary_results = layers.filter( + layer__name__icontains=search_term).exclude( + pk__in=primary_results) results = [] @@ -49,97 +49,99 @@ class LayersTypeAhead(ToasterTypeAhead): detail = "[ %s | %s ]" % (layer_version.layer.vcs_url, vcs_reference) needed_fields = { - 'id' : layer_version.pk, - 'name' : layer_version.layer.name, - 'layerdetailurl' : layer_version.get_detailspage_url(prj.pk), - 'vcs_url' : layer_version.layer.vcs_url, - 'vcs_reference' : vcs_reference, - 'detail' : detail, - 'local_source_dir' : layer_version.layer.local_source_dir, + 'id': layer_version.pk, + 'name': layer_version.layer.name, + 'layerdetailurl': layer_version.get_detailspage_url(prj.pk), + 'vcs_url': layer_version.layer.vcs_url, + 'vcs_reference': vcs_reference, + 'detail': detail, + 'local_source_dir': layer_version.layer.local_source_dir, } results.append(needed_fields) return results + class MachinesTypeAhead(ToasterTypeAhead): """ Typeahead for all the machines available in the current project's configuration """ - def __init__(self): - super(MachinesTypeAhead, self).__init__() def apply_search(self, search_term, prj, request): machines = prj.get_available_machines() machines = machines.order_by("name") primary_results = machines.filter(name__istartswith=search_term) - secondary_results = machines.filter(name__icontains=search_term).exclude(pk__in=primary_results) - tertiary_results = machines.filter(layer_version__layer__name__icontains=search_term).exclude(pk__in=primary_results).exclude(pk__in=secondary_results) + secondary_results = machines.filter( + name__icontains=search_term).exclude(pk__in=primary_results) + tertiary_results = machines.filter( + layer_version__layer__name__icontains=search_term).exclude( + pk__in=primary_results).exclude(pk__in=secondary_results) results = [] - for machine in list(primary_results) + list(secondary_results) + list(tertiary_results): + for machine in list(primary_results) + list(secondary_results) + \ + list(tertiary_results): detail = "[ %s ]" % (machine.layer_version.layer.name) needed_fields = { - 'id' : machine.pk, - 'name' : machine.name, - 'detail' : detail, + 'id': machine.pk, + 'name': machine.name, + 'detail': detail, } results.append(needed_fields) - return results + class RecipesTypeAhead(ToasterTypeAhead): """ Typeahead for all the recipes available in the current project's configuration """ - def __init__(self): - super(RecipesTypeAhead, self).__init__() - def apply_search(self, search_term, prj, request): recipes = prj.get_available_recipes() recipes = recipes.order_by("name") - primary_results = recipes.filter(name__istartswith=search_term) - secondary_results = recipes.filter(name__icontains=search_term).exclude(pk__in=primary_results) - tertiary_results = recipes.filter(layer_version__layer__name__icontains=search_term).exclude(pk__in=primary_results).exclude(pk__in=secondary_results) + secondary_results = recipes.filter( + name__icontains=search_term).exclude(pk__in=primary_results) + tertiary_results = recipes.filter( + layer_version__layer__name__icontains=search_term).exclude( + pk__in=primary_results).exclude(pk__in=secondary_results) results = [] - for recipe in list(primary_results) + list(secondary_results) + list(tertiary_results): + for recipe in list(primary_results) + list(secondary_results) + \ + list(tertiary_results): detail = "[ %s ]" % (recipe.layer_version.layer.name) needed_fields = { - 'id' : recipe.pk, - 'name' : recipe.name, - 'detail' : detail, + 'id': recipe.pk, + 'name': recipe.name, + 'detail': detail, } results.append(needed_fields) return results + class ProjectsTypeAhead(ToasterTypeAhead): """ Typeahead for all the projects, except for command line builds """ - def __init__(self): - super(ProjectsTypeAhead, self).__init__() - def apply_search(self, search_term, prj, request): projects = Project.objects.exclude(is_default=True).order_by("name") primary_results = projects.filter(name__istartswith=search_term) - secondary_results = projects.filter(name__icontains=search_term).exclude(pk__in=primary_results) + secondary_results = projects.filter( + name__icontains=search_term).exclude(pk__in=primary_results) results = [] for project in list(primary_results) + list(secondary_results): needed_fields = { - 'id' : project.pk, - 'name' : project.name, - 'detail' : "", - 'projectPageUrl' : reverse('project', args=(project.pk,)) + 'id': project.pk, + 'name': project.name, + 'detail': "", + 'projectPageUrl': reverse('project', args=(project.pk,)) } results.append(needed_fields) diff --git a/bitbake/lib/toaster/toastergui/widgets.py b/bitbake/lib/toaster/toastergui/widgets.py index 026903d..6b7b981 100644 --- a/bitbake/lib/toaster/toastergui/widgets.py +++ b/bitbake/lib/toaster/toastergui/widgets.py @@ -42,6 +42,8 @@ import json import collections import re +from toastergui.tablefilter import TableFilterMap + try: from urllib import unquote_plus except ImportError: @@ -50,8 +52,6 @@ except ImportError: import logging logger = logging.getLogger("toaster") -from toastergui.tablefilter import TableFilterMap - class NoFieldOrDataName(Exception): pass @@ -259,9 +259,9 @@ class ToasterTable(TemplateView): queries = query if search_queries: - search_queries &= queries + search_queries &= queries else: - search_queries = queries + search_queries = queries self.queryset = self.queryset.filter(search_queries) -- 2.7.4