mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-23 23:02:25 +00:00
web: move plural() to common.py
This commit is contained in:
parent
67571eb033
commit
c4bda3daa3
@ -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")
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user