web: move plural() to common.py

This commit is contained in:
Brian Warner 2009-03-03 19:40:19 -07:00
parent 67571eb033
commit c4bda3daa3
2 changed files with 10 additions and 10 deletions

View File

@ -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")

View File

@ -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):