optionaly display short runtime, add languages2Letter
This commit is contained in:
parent
832176181c
commit
406fc19606
2 changed files with 13 additions and 3 deletions
|
@ -139,7 +139,7 @@ def plural(amount, unit, plural='s'):
|
||||||
else: unit = plural
|
else: unit = plural
|
||||||
return "%s %s" % (formatThousands(amount), unit)
|
return "%s %s" % (formatThousands(amount), unit)
|
||||||
|
|
||||||
def ms2runtime(ms):
|
def ms2runtime(ms, shortenLong=False):
|
||||||
'''
|
'''
|
||||||
>>> ms2runtime(5000)
|
>>> ms2runtime(5000)
|
||||||
'5 seconds'
|
'5 seconds'
|
||||||
|
@ -167,8 +167,11 @@ def ms2runtime(ms):
|
||||||
if days >= 365:
|
if days >= 365:
|
||||||
years = int(days / 365)
|
years = int(days / 365)
|
||||||
days = days % 365
|
days = days % 365
|
||||||
runtimeString = (plural(years, 'year'), plural(days, 'day'),
|
if shortenLong and years > 0 or days > 99:
|
||||||
plural(hours,'hour'), plural(minutes, 'minute'), plural(seconds, 'second'))
|
runtimeString = ("%sy" % years, "%sd" % days, "%sh" % hours, "%sm" % minutes, "%ss" % seconds)
|
||||||
|
else:
|
||||||
|
runtimeString = (plural(years, 'year'), plural(days, 'day'),
|
||||||
|
plural(hours,'hour'), plural(minutes, 'minute'), plural(seconds, 'second'))
|
||||||
runtimeString = filter(lambda x: not x.startswith('0'), runtimeString)
|
runtimeString = filter(lambda x: not x.startswith('0'), runtimeString)
|
||||||
return " ".join(runtimeString).strip()
|
return " ".join(runtimeString).strip()
|
||||||
|
|
||||||
|
|
|
@ -234,3 +234,10 @@ def englishName(lang):
|
||||||
return l[0]
|
return l[0]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def languages2Letter():
|
||||||
|
languages = []
|
||||||
|
for l in _iso639_languages:
|
||||||
|
if l[2]:
|
||||||
|
languages.append(l[2])
|
||||||
|
return languages
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue