From 9922fd76c9acff6a20868a05d3783439e6b0d630 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Mon, 20 Feb 2012 13:29:11 -0500 Subject: [PATCH] cleanup --- httpbin/filters.py | 5 +---- httpbin/utils.py | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/httpbin/filters.py b/httpbin/filters.py index b0b16e2..494deca 100644 --- a/httpbin/filters.py +++ b/httpbin/filters.py @@ -13,7 +13,6 @@ from cStringIO import StringIO from decimal import Decimal from time import time as now -import omnijson from decorator import decorator from flask import Flask, Response @@ -21,7 +20,6 @@ from flask import Flask, Response app = Flask(__name__) - @decorator def x_runtime(f, *args, **kwargs): """X-Runtime Flask Response Decorator.""" @@ -29,7 +27,7 @@ def x_runtime(f, *args, **kwargs): _t0 = now() r = f(*args, **kwargs) _t1 = now() - r.headers['X-Runtime'] = '{0}s'.format(Decimal(str(_t1-_t0))) + r.headers['X-Runtime'] = '{0}s'.format(Decimal(str(_t1 - _t0))) return r @@ -38,7 +36,6 @@ def x_runtime(f, *args, **kwargs): def gzip(f, *args, **kwargs): """GZip Flask Response Decorator.""" - data = f(*args, **kwargs) if isinstance(data, Response): diff --git a/httpbin/utils.py b/httpbin/utils.py index 35161a6..6e2e059 100644 --- a/httpbin/utils.py +++ b/httpbin/utils.py @@ -10,6 +10,7 @@ Utility functions. import random import bisect + def weighted_choice(choices): """Returns a value from choices chosen by weighted random selection @@ -26,4 +27,4 @@ def weighted_choice(choices): cum_weights.append(total) x = random.uniform(0, total) i = bisect.bisect(cum_weights, x) - return values[i] \ No newline at end of file + return values[i]