From 1446cc72b7c53db1caa1bae149a405055c9d6ad7 Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Thu, 2 May 2013 19:28:24 +0200 Subject: webapp: use jinja's filesizeformat Except it doesn't work, so replace it with our version. At least we might be able to drop this code in a future update. --- webapp.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'webapp.py') diff --git a/webapp.py b/webapp.py index 2cc8a7e..b5aa460 100755 --- a/webapp.py +++ b/webapp.py @@ -41,7 +41,8 @@ def function_combination(function1, function2): return function1 return "%s -> %s" % (function1, function2) -jinjaenv.filters["format_size"] = format_size +# Workaround for jinja bug #59 (broken filesizeformat) +jinjaenv.filters["filesizeformat"] = format_size base_template = jinjaenv.get_template("base.html") @@ -52,7 +53,7 @@ package_template = jinjaenv.from_string(

Version: {{ version|e }}

Architecture: {{ architecture|e }}

Number of files: {{ num_files }}

-

Total size: {{ total_size|format_size }}

+

Total size: {{ total_size|filesizeformat }}

{%- if shared -%} {%- for function, sharing in shared.items() -%}

sharing with respect to {{ function|e }}

@@ -62,7 +63,7 @@ package_template = jinjaenv.from_string( {%- if entry.package %}{{ entry.package|e }}{% else %}self{% endif %} compare {{ entry.duplicate }} ({{ (100 * entry.duplicate / num_files)|int }}%) - {{ entry.savable|format_size }} ({{ (100 * entry.savable / total_size)|int }}%) + {{ entry.savable|filesizeformat }} ({{ (100 * entry.savable / total_size)|int }}%) {%- endfor -%} {%- endfor -%} @@ -78,7 +79,7 @@ detail_template = jinjaenv.from_string( {%- for entry in shared -%} - 1 %} rowspan={{ entry.matches|length }}{% endif %}>{{ entry.size|format_size }} 1 %} rowspan={{ entry.matches|length }}{% endif %}> + 1 %} rowspan={{ entry.matches|length }}{% endif %}>{{ entry.size|filesizeformat }} 1 %} rowspan={{ entry.matches|length }}{% endif %}> {%- for filename in entry.filenames %}{{ filename|e }}{% endfor -%} {% endfor %} -- cgit v1.2.3
{{ details1.package|e }}{{ details2.package|e }}
sizefilenamehash functionsfilename
{% for filename, match in entry.matches.items() -%} {% if not loop.first %}
{% endif -%} @@ -101,7 +102,7 @@ hash_template = jinjaenv.from_string( {%- for entry in entries -%} - + {%- endfor -%}
packagefilenamesizedifferent function
{{ entry.package|e }}{{ entry.filename|e }}{{ entry.size|format_size }}{{ entry.filename|e }}{{ entry.size|filesizeformat }} {% if function != entry.function %}{{ entry.function|e }}{% endif %}
@@ -162,7 +163,7 @@ source_template = jinjaenv.from_string( {% for package, sharing in packages.items() %}
{{ package|e }} {%- if sharing -%} - {{ sharing.savable|format_size }}{{ sharing.package|e }} compare + {{ sharing.savable|filesizeformat }}{{ sharing.package|e }} compare {%- else -%}{%- endif -%}