From: Brian Warner Date: Wed, 4 Mar 2009 02:40:19 +0000 (-0700) Subject: web: move plural() to common.py X-Git-Url: https://git.rkrishnan.org/pf/content/%22file:/frontends/-?a=commitdiff_plain;h=c4bda3daa301f3c472332785556fe674df6e38c9;p=tahoe-lafs%2Ftahoe-lafs.git web: move plural() to common.py --- diff --git a/src/allmydata/web/common.py b/src/allmydata/web/common.py index ec86d46a..5f7e76e6 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 d5ce1c69..4fba764c 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):