diff --git a/anki/stats.py b/anki/stats.py
index 7509b870a..91dda8fda 100644
--- a/anki/stats.py
+++ b/anki/stats.py
@@ -260,6 +260,7 @@ class CardStats(object):
def report(self):
c = self.card
fmt = anki.utils.fmtTimeSpan
+ fmtFloat = anki.utils.fmtFloat
self.txt = "
"
self.addLine(_("Added"), self.strTime(c.created))
if c.firstAnswered:
@@ -272,21 +273,21 @@ class CardStats(object):
next = _("in %s") % fmt(abs(next))
self.addLine(_("Due"), next)
self.addLine(_("Interval"), fmt(c.interval * 86400))
- self.addLine(_("Ease"), "%0.2f" % c.factor)
+ self.addLine(_("Ease"), fmtFloat(c.factor, point=2))
if c.lastDue:
last = _("%s ago") % fmt(time.time() - c.lastDue)
self.addLine(_("Last Due"), last)
if c.interval != c.lastInterval:
# don't show the last interval if it hasn't been updated yet
self.addLine(_("Last Interval"), fmt(c.lastInterval * 86400))
- self.addLine(_("Last Ease"), "%0.2f" % c.lastFactor)
+ self.addLine(_("Last Ease"), fmtFloat(c.lastFactor, point=2))
if c.reps:
self.addLine(_("Reviews"), "%d/%d (s=%d)" % (
c.yesCount, c.reps, c.successive))
- self.addLine(_("Average Time"), _("%0.1f seconds") %
- c.averageTime)
- self.addLine(_("Total Time"), _("%0.1f seconds") %
- c.reviewTime)
+ avg = fmt(c.averageTime, point=2)
+ self.addLine(_("Average Time"),avg)
+ total = fmt(c.reviewTime, point=2)
+ self.addLine(_("Total Time"), total)
self.addLine(_("Model Tags"), c.fact.model.tags)
self.addLine(_("Card Template") + " "*5, c.cardModel.name)
self.txt += "
"
@@ -309,8 +310,10 @@ class DeckStats(object):
def report(self):
"Return an HTML string with a report."
+ fmtPerc = anki.utils.fmtPercentage
+ fmtFloat = anki.utils.fmtFloat
if self.deck.isEmpty():
- return _("Please add some cards first.")
+ return _("Please add some cards first.") + ""
d = self.deck
html="" + _("Deck Statistics") + "
"
html += _("Deck created: %s ago
") % self.createdTimeStr()
@@ -325,60 +328,60 @@ class DeckStats(object):
(stats["new"], stats["newP"]) = (new, newP)
(stats["old"], stats["oldP"]) = (old, oldP)
(stats["young"], stats["youngP"]) = (young, youngP)
- html += _("Total number of cards: %d
") % total
- html += _("Total number of facts: %d
") % d.factCount
+ html += _("Total number of cards:") + " %d
" % total
+ html += _("Total number of facts:") + " %d
" % d.factCount
- html += _("Card counts
")
- html += _("Mature cards: %(old)d "
- "(%(oldP)0.2f%%)
") % stats
- html += _("Young cards: %(young)d "
- "(%(youngP)0.2f%%)
") % stats
- html += _("Unseen cards: %(new)d "
- "(%(newP)0.2f%%)
") % stats
+ html += "" + _("Card counts") + "
"
+ html += _("Mature cards:") + " %(old)d (%(oldP)s)
" % {'old': stats['old'], 'oldP' : fmtPerc(stats['oldP'])}
+ html += _("Young cards:") + " %(young)d (%(youngP)s)
" % {'young': stats['young'], 'youngP' : fmtPerc(stats['youngP'])}
+ html += _("Unseen cards:") + " %(new)d (%(newP)s)
" % {'new': stats['new'], 'newP' : fmtPerc(stats['newP'])}
- html += _("Correct answers
")
- html += _("Mature cards: %(gMatureYes%)0.1f%% "
- "(%(gMatureYes)d of %(gMatureTotal)d)
") % stats
- html += _("Young cards: %(gYoungYes%)0.1f%% "
- "(%(gYoungYes)d of %(gYoungTotal)d)
") % stats
- html += _("First-seen cards: %(gNewYes%)0.1f%% "
- "(%(gNewYes)d of %(gNewTotal)d)
") % stats
+ html += "" + _("Correct answers") + "
"
+ html += _("Mature cards:") + "" + fmtPerc(stats['gMatureYes%']) + (
+ " " + _("%(partOf)d of %(totalSum)d") % {'partOf' : stats['gMatureYes'],
+ 'totalSum' : stats['gMatureTotal'] } + "
")
+ html += _("Young cards:") + " " + fmtPerc(stats['gYoungYes%']) + (
+ " " + _("%(partOf)d of %(totalSum)d") % {'partOf' : stats['gYoungYes'],
+ 'totalSum' : stats['gYoungTotal'] } + "
")
+ html += _("First-seen cards:") + " " + fmtPerc(stats['gNewYes%']) + (
+ " " + _("%(partOf)d of %(totalSum)d") % {'partOf' : stats['gNewYes'],
+ 'totalSum' : stats['gNewTotal'] } + "
")
# average pending time
existing = d.cardCount - d.newCountToday
avgInt = self.getAverageInterval()
def tr(a, b):
return "%s | %s |
" % (a, b)
if existing and avgInt:
- html += _("Averages
")
+ html += "" + _("Averages") + ""
if sys.platform.startswith("darwin"):
html += ""
else:
html += ""
- html += tr(_("Interval"), _("%0.0f days") % avgInt)
- html += tr(_("Average reps"), _("%0.1f cards/day") % (
- self.getSumInverseRoundInterval()))
- html += tr(_("Reps next week"), _("%0.1f cards/day") % (
- self.getWorkloadPeriod(7)))
- html += tr(_("Reps next month"), _("%0.1f cards/day") % (
- self.getWorkloadPeriod(30)))
- html += tr(_("Reps last week"), _("%0.1f cards/day") % (
- self.getPastWorkloadPeriod(7)))
- html += tr(_("Reps last month"), _("%0.1f cards/day") % (
- self.getPastWorkloadPeriod(30)))
- html += tr(_("Avg. added"), _("%(a)d/day, %(b)d/mon") % {
- 'a': self.newAverage(), 'b': self.newAverage()*30})
+ html += tr(_("Interval"), ("%s ") % fmtFloat(avgInt) + _("days") )
+ html += tr(_("Average reps"), ("%s ") % (
+ fmtFloat(self.getSumInverseRoundInterval())) + _("cards/day"))
+ html += tr(_("Reps next week"), ("%s ") % (
+ fmtFloat(self.getWorkloadPeriod(7))) + _("cards/day"))
+ html += tr(_("Reps next month"), ("%s ") % (
+ fmtFloat(self.getWorkloadPeriod(30))) + _("cards/day"))
+ html += tr(_("Reps last week"), ("%s ") % (
+ fmtFloat(self.getPastWorkloadPeriod(7))) + _("cards/day"))
+ html += tr(_("Reps last month"), ("%s ") % (
+ fmtFloat(self.getPastWorkloadPeriod(30))) + _("cards/day"))
+ html += tr(_("Avg. added"), _("%(a)s/day, %(b)s/mon") % {
+ 'a': fmtFloat(self.newAverage()), 'b': fmtFloat(self.newAverage()*30)})
np = self.getNewPeriod(7)
- html += tr(_("Added last week"), _("%(a)d (%(b)0.1f/day)") % (
- {'a': np, 'b': np / float(7)}))
+ html += tr(_("Added last week"), _("%(a)d (%(b)s/day)") % (
+ {'a': np, 'b': fmtFloat(np / float(7))}))
np = self.getNewPeriod(30)
- html += tr(_("Added last month"), _("%(a)d (%(b)0.1f/day)") % (
- {'a': np, 'b': np / float(30)}))
+ html += tr(_("Added last month"), _("%(a)d (%(b)s/day)") % (
+ {'a': np, 'b': fmtFloat(np / float(30))}))
np = self.getFirstPeriod(7)
- html += tr(_("First last week"), _("%(a)d (%(b)0.1f/day)") % (
- {'a': np, 'b': np / float(7)}))
+ html += tr(_("First last week"), _("%(a)d (%(b)s/day)") % (
+ {'a': np, 'b': fmtFloat(np / float(7))}))
np = self.getFirstPeriod(30)
- html += tr(_("First last month"), _("%(a)d (%(b)0.1f/day)") % (
- {'a': np, 'b': np / float(30)}))
+ html += tr(_("First last month"), _("%(a)d (%(b)s/day)") % (
+ {'a': np, 'b': fmtFloat(np / float(30))}))
html += "
"
return html
@@ -394,10 +397,10 @@ class DeckStats(object):
html = ""
for key in keys:
html += ("%s | " +
- "%d | %0.2f%% |
") % (
+ "%d%s | ") % (
labels[key],
boxes[key],
- boxes[key] / float(total) * 100)
+ fmtPerc(boxes[key] / float(total) * 100))
return html
def splitIntoIntervals(self, intervals):