summaryrefslogtreecommitdiff
path: root/webapp.py
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2013-03-05 08:38:39 +0100
committerHelmut Grohne <helmut@subdivi.de>2013-03-05 08:38:39 +0100
commit0aee3024491a16746691ec35436bbf05cffe0dc7 (patch)
tree184a9263938f58b07198193a8660b496c2d13150 /webapp.py
parente58d032e075a8c96cbeb353154c8b483feb64871 (diff)
downloaddebian-dedup-0aee3024491a16746691ec35436bbf05cffe0dc7.tar.gz
webapp: helper function function_combination
Diffstat (limited to 'webapp.py')
-rwxr-xr-xwebapp.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/webapp.py b/webapp.py
index 9564b7c..893a31d 100755
--- a/webapp.py
+++ b/webapp.py
@@ -35,6 +35,11 @@ def format_size(size):
fmt = "%.1f GB"
return fmt % size
+def function_combination(function1, function2):
+ if function1 == function2:
+ return function1
+ return "%s -> %s" % (function1, function2)
+
jinjaenv.filters["format_size"] = format_size
base_template = jinjaenv.get_template("base.html")
@@ -241,11 +246,7 @@ class Application(object):
fileset = hashdict.setdefault(hashval, (size, set()))[1]
fileset.add(afile)
if sharing:
- curstats = list()
- if func1 == func2:
- sharedstats[func1] = curstats
- else:
- sharedstats["%s -> %s" % (func1, func2)] = curstats
+ sharedstats[function_combination(func1, func2)] = curstats = []
mapping = sharing.pop(package, dict())
if mapping:
duplicate = sum(len(files) for _, files in mapping.values())
@@ -265,11 +266,8 @@ class Application(object):
for package2, func1, func2, files, size in fetchiter(cur):
if (func1, func2) not in hash_functions:
continue
- if func1 == func2:
- func = func1
- else:
- func = "%s -> %s" % (func1, func2)
- curstats = sharedstats.setdefault(func, list())
+ curstats = sharedstats.setdefault(
+ function_combination(func1, func2), list())
if package2 == package:
package2 = None
curstats.append(dict(package=package2, duplicate=files, savable=size))