You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by tv...@apache.org on 2013/08/28 16:35:27 UTC
[46/50] git commit: [#6482] simpler logic to build matrix of
importers (thanks Cory)
[#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/ec9c7cf0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/ec9c7cf0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/ec9c7cf0
Branch: refs/heads/tv/6526
Commit: ec9c7cf0004f44b1b042aef9b83d22235d92da40
Parents: 7f179dc
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Tue Aug 13 21:12:37 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Aug 27 17:24:58 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/ec9c7cf0/ForgeImporters/forgeimporters/base.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/base.py b/ForgeImporters/forgeimporters/base.py
index e957b1a..e80235e 100644
--- a/ForgeImporters/forgeimporters/base.py
+++ b/ForgeImporters/forgeimporters/base.py
@@ -360,33 +360,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/ec9c7cf0/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 @@
<thead>
<tr>
<th></th>
- {% for tool in tools %}
- <th>{{tool.tool_label}}</th>
+ {% for tool in tools|sort %}
+ <th>{{tool}}</th>
{% endfor %}
</tr>
</thead>
- {% for source, importers in importer_matrix|dictsort %}
+ {% for source in importer_matrix.keys()|sort %}
<tr>
<td><strong>{{ source }}</strong></td>
- {% for importer_name in importers %}
+ {% for tool in tools|sort %}
<td>
- {% if importer_name %}
- <a href="{{importer_name}}">Import</a>
+ {% if importer_matrix[source].get(tool) %}
+ <a href="{{ importer_matrix[source][tool] }}">Import</a>
{% endif %}
</td>
{% endfor %}