From c4bda3daa301f3c472332785556fe674df6e38c9 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Tue, 3 Mar 2009 19:40:19 -0700 Subject: [PATCH] web: move plural() to common.py --- src/allmydata/web/common.py | 9 +++++++++ src/allmydata/web/status.py | 11 +---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/allmydata/web/common.py b/src/allmydata/web/common.py index ec86d46a5..5f7e76e6c 100644 --- a/src/allmydata/web/common.py +++ b/src/allmydata/web/common.py @@ -81,6 +81,15 @@ def abbreviate_size(data): return "%.1fkB" % (r/1000) return "%dB" % r +def plural(sequence_or_length): + if isinstance(sequence_or_length, int): + length = sequence_or_length + else: + length = len(sequence_or_length) + if length == 1: + return "" + return "s" + def text_plain(text, ctx): req = IRequest(ctx) req.setHeader("content-type", "text/plain") diff --git a/src/allmydata/web/status.py b/src/allmydata/web/status.py index d5ce1c697..4fba764c1 100644 --- a/src/allmydata/web/status.py +++ b/src/allmydata/web/status.py @@ -5,19 +5,10 @@ from twisted.internet import defer from nevow import rend, inevow, tags as T from allmydata.util import base32, idlib from allmydata.web.common import getxmlfile, get_arg, \ - abbreviate_time, abbreviate_rate, abbreviate_size + abbreviate_time, abbreviate_rate, abbreviate_size, plural from allmydata.interfaces import IUploadStatus, IDownloadStatus, \ IPublishStatus, IRetrieveStatus, IServermapUpdaterStatus -def plural(sequence_or_length): - if isinstance(sequence_or_length, int): - length = sequence_or_length - else: - length = len(sequence_or_length) - if length == 1: - return "" - return "s" - class RateAndTimeMixin: def render_time(self, ctx, data):