Return-Path: X-Original-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D961A10179 for ; Tue, 13 Aug 2013 21:13:11 +0000 (UTC) Received: (qmail 40428 invoked by uid 500); 13 Aug 2013 21:13:11 -0000 Delivered-To: apmail-incubator-allura-commits-archive@incubator.apache.org Received: (qmail 40412 invoked by uid 500); 13 Aug 2013 21:13:11 -0000 Mailing-List: contact allura-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: allura-dev@incubator.apache.org Delivered-To: mailing list allura-commits@incubator.apache.org Received: (qmail 40404 invoked by uid 99); 13 Aug 2013 21:13:11 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Aug 2013 21:13:11 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 626508BE1CD; Tue, 13 Aug 2013 21:13:11 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: brondsem@apache.org To: allura-commits@incubator.apache.org Message-Id: <1131d49d08b94d0eae951fda7d739593@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: [#6482] simpler logic to build matrix of importers (thanks Cory) Date: Tue, 13 Aug 2013 21:13:11 +0000 (UTC) Updated Branches: refs/heads/db/6482 51c3cbac5 -> 7ece9b7d5 [#6482] simpler logic to build matrix of importers (thanks Cory) Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/7ece9b7d Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/7ece9b7d Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/7ece9b7d Branch: refs/heads/db/6482 Commit: 7ece9b7d59b236b80ce7ed0958643eb60dfdb723 Parents: 51c3cba Author: Dave Brondsema Authored: Tue Aug 13 21:12:37 2013 +0000 Committer: Dave Brondsema Committed: Tue Aug 13 21:12:37 2013 +0000 ---------------------------------------------------------------------- ForgeImporters/forgeimporters/base.py | 27 ++++---------------- .../forgeimporters/templates/list_all.html | 12 ++++----- 2 files changed, 11 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7ece9b7d/ForgeImporters/forgeimporters/base.py ---------------------------------------------------------------------- diff --git a/ForgeImporters/forgeimporters/base.py b/ForgeImporters/forgeimporters/base.py index 0897a02..eeb54d2 100644 --- a/ForgeImporters/forgeimporters/base.py +++ b/ForgeImporters/forgeimporters/base.py @@ -276,33 +276,16 @@ class ProjectToolsImportController(object): @with_trailing_slash @expose('jinja:forgeimporters:templates/list_all.html') def index(self, *a, **kw): - # make dictionaries of both axis - importers_by_source = defaultdict(dict) - importers_by_tool = defaultdict(dict) + importer_matrix = defaultdict(dict) + tools_with_importers = set() for ep in iter_entry_points('allura.importers'): importer = ep.load() - importers_by_source[importer.source][ep.name] = importer for tool in aslist(importer.target_app): - importers_by_tool[tool][ep.name] = importer - - relevant_tools = sorted(importers_by_tool.keys(), key=lambda t: t.tool_label) - - # build a full matrix including empty spots - importer_matrix = dict() # source -> [importer names] - for source, src_importers in importers_by_source.iteritems(): - row = list() - for tool in relevant_tools: - for ep_name, importer in src_importers.iteritems(): - if tool in aslist(importer.target_app): - row.append(ep_name) - break - else: - row.append(None) - importer_matrix[source] = row - + tools_with_importers.add(tool.tool_label) + importer_matrix[importer.source][tool.tool_label] = ep.name return { - 'tools': relevant_tools, 'importer_matrix': importer_matrix, + 'tools': tools_with_importers, } @expose() http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7ece9b7d/ForgeImporters/forgeimporters/templates/list_all.html ---------------------------------------------------------------------- diff --git a/ForgeImporters/forgeimporters/templates/list_all.html b/ForgeImporters/forgeimporters/templates/list_all.html index b91e0df..b4c0a06 100644 --- a/ForgeImporters/forgeimporters/templates/list_all.html +++ b/ForgeImporters/forgeimporters/templates/list_all.html @@ -31,18 +31,18 @@ - {% for tool in tools %} - {{tool.tool_label}} + {% for tool in tools|sort %} + {{tool}} {% endfor %} - {% for source, importers in importer_matrix|dictsort %} + {% for source in importer_matrix.keys()|sort %} {{ source }} - {% for importer_name in importers %} + {% for tool in tools|sort %} - {% if importer_name %} - Import + {% if importer_matrix[source].get(tool) %} + Import {% endif %} {% endfor %}