mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 20:59:01 +02:00
Add basic CSV export for other distro comparisons
Add the ability to export the comparison search results to CSV format in order to allow importing the data into external tools. Note: I implemented this in a different way than the earlier recipe CSV export, i.e. it uses a template to render the CSV instead of a function-based view with the Python csv module - the reason for this is we can reuse the same view as we use for producing the search, with all of the flexibility that gives us. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
parent
09ef043f3f
commit
fb2907a5d8
12
layerindex/templatetags/extrafilters.py
Normal file
12
layerindex/templatetags/extrafilters.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
from django import template
|
||||
from .. import utils
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@register.filter
|
||||
def replace_commas(string):
|
||||
return string.replace(',', '_')
|
||||
|
||||
@register.filter
|
||||
def squashspaces(strval):
|
||||
return utils.squashspaces(strval)
|
|
@ -142,6 +142,12 @@ urlpatterns = [
|
|||
ClassicRecipeSearchView.as_view(
|
||||
template_name='layerindex/classicrecipes.html'),
|
||||
name='comparison_recipe_search'),
|
||||
url(r'^comparison/search-csv/(?P<branch>[-\w]+)/$',
|
||||
ClassicRecipeSearchView.as_view(
|
||||
template_name='layerindex/classicrecipes_csv.txt',
|
||||
paginate_by=0,
|
||||
content_type='text/csv'),
|
||||
name='comparison_recipe_search_csv'),
|
||||
url(r'^comparison/stats/(?P<branch>[-\w]+)/$',
|
||||
ClassicRecipeStatsView.as_view(
|
||||
template_name='layerindex/classicstats.html'),
|
||||
|
|
|
@ -14,6 +14,7 @@ import time
|
|||
import fcntl
|
||||
import signal
|
||||
import codecs
|
||||
import re
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
def get_branch(branchname):
|
||||
|
@ -430,3 +431,5 @@ def sanitise_html(html):
|
|||
|
||||
return soup.renderContents()
|
||||
|
||||
def squashspaces(string):
|
||||
return re.sub("\s+", " ", string).strip()
|
||||
|
|
|
@ -123,6 +123,7 @@
|
|||
</tbody>
|
||||
</table>
|
||||
<button class="btn" type="submit">Search</button>
|
||||
<button class="btn" type="submit" formaction="{% url 'comparison_recipe_search_csv' branch.name %}">Export CSV</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
|
2
templates/layerindex/classicrecipes_csv.txt
Normal file
2
templates/layerindex/classicrecipes_csv.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
{% load extrafilters %}{% for recipe in recipe_list %}{{ recipe.name }},{{ recipe.layerbranch.layer.name }},{{ recipe.short_desc|replace_commas|squashspaces }},{{ recipe.section }},{% if recipe.cover_recipe %}{{ recipe.cover_recipe.get_cover_status_display }}{% endif %},{% if recipe.cover_recipe %}{{ recipe.cover_recipe.pn }}{% endif %}
|
||||
{% endfor %}
|
Loading…
Reference in New Issue
Block a user