[damned-lies] Replaced obsolete SortedDict by OrderedDict
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Replaced obsolete SortedDict by OrderedDict
- Date: Wed, 9 Sep 2015 15:12:13 +0000 (UTC)
commit 6d8f5d12c7f05121f8a1caea23e0fc0762a9e5e2
Author: Claude Paroz <claude 2xlibre net>
Date: Wed Sep 9 17:11:41 2015 +0200
Replaced obsolete SortedDict by OrderedDict
README | 4 ++--
stats/models.py | 23 ++++++++++-------------
2 files changed, 12 insertions(+), 15 deletions(-)
---
diff --git a/README b/README
index d1adf86..73758ae 100644
--- a/README
+++ b/README
@@ -10,8 +10,8 @@ Requirements
1 - Django > 1.7.X
-2 - Python 2.6 (minimal)
- PIL (python-imaging) or pillow for hackergotchi checks.
+2 - Python 2.7 (minimal)
+ pillow (python-pillow) for hackergotchi checks.
Markdown (python-markdown) for Team presentation markup rendering.
3 - gettext, intltool, gnome-doc-utils (for stats generation), itstool
diff --git a/stats/models.py b/stats/models.py
index 8ee3af9..83a1a9b 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -18,7 +18,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
-from collections import Counter
+from collections import Counter, OrderedDict
import fnmatch
import logging
import os, sys, re
@@ -33,7 +33,6 @@ from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from django.utils.translation import ungettext, ugettext as _, ugettext_noop
from django.utils import dateformat
-from django.utils.datastructures import SortedDict
from django.db import models, connection
from common.fields import DictionaryField, JSONField
@@ -352,7 +351,7 @@ class Branch(models.Model):
'po-tips': [potstat, polang1, polang2, ...]}
mandatory_langs is a list of language objects whose stats should be added even if no translation
exists.
"""
- stats = SortedDict(); stats_langs = {}
+ stats = OrderedDict(); stats_langs = {}
pot_stats = Statistics.objects.select_related("language", "domain", "branch", "full_po"
).filter(branch=self, language__isnull=True, domain__dtype=typ
).order_by('domain__name')
@@ -1586,7 +1585,7 @@ class Statistics(models.Model):
'totaltransperc': 0,
'totalfuzzyperc': 0,
'totaluntransperc': 0,
- 'categs': { # SortedDict
+ 'categs': { # OrderedDict
<categkey>: {
'catname': <catname>, # translated category name (see CATEGORY_CHOICES)
'cattotal': 0,
@@ -1594,7 +1593,7 @@ class Statistics(models.Model):
'catfuzzy': 0,
'catuntrans': 0,
'cattransperc': 0,
- 'modules': { # SortedDict
+ 'modules': { # OrderedDict
<module>: {
<branchname>:
[(<domname>, <stat>), ...], # List of tuples (domain name, Statistics
object)
@@ -1618,13 +1617,13 @@ class Statistics(models.Model):
stats = {'dtype':dtype, 'totaltrans':0, 'totalfuzzy':0, 'totaluntrans':0,
'totaltransperc': 0, 'totalfuzzyperc': 0, 'totaluntransperc': 0,
- 'categs': SortedDict(), 'all_errors': []}
+ 'categs': OrderedDict(), 'all_errors': []}
# Sorted by module to allow grouping ('fake' stats)
pot_stats = Statistics.objects.select_related('domain', 'branch__module', 'full_po', 'part_po')
if release:
- pot_stats = pot_stats.extra(select={'categ_name': "category.name"}).filter(language=None,
branch__releases=release, domain__dtype=dtype).order_by('branch__module__id')
+ pot_stats = pot_stats.extra(select={'categ_name': "category.name"}).filter(language=None,
branch__releases=release, domain__dtype=dtype).order_by('branch__module__name')
else:
- pot_stats = pot_stats.filter(language=None, domain__dtype=dtype).order_by('branch__module__id')
+ pot_stats = pot_stats.filter(language=None, domain__dtype=dtype).order_by('branch__module__name')
tr_stats = Statistics.objects.select_related('domain', 'language', 'branch__module', 'full_po',
'part_po')
if release:
@@ -1650,7 +1649,7 @@ class Statistics(models.Model):
if vt_state.id in actions_dict:
vt_state.last_comment = actions_dict[vt_state.id].comment
- category_choices_dict = SortedDict(CATEGORY_CHOICES)
+ category_choices_dict = OrderedDict(CATEGORY_CHOICES)
for stat in pot_stats:
categ_key = "default"
if release:
@@ -1662,7 +1661,7 @@ class Statistics(models.Model):
stats['categs'][categ_key] = {
'cattrans': 0, 'catfuzzy': 0, 'catuntrans': 0, 'cattransperc': 0,
'catname': _(category_choices_dict[getattr(stat, 'categ_name', 'default')]),
- 'modules': SortedDict(),
+ 'modules': OrderedDict(),
}
# Try to get translated stat, else stick with POT stat
br_dom_key = "%d-%d" % (stat.branch.id, stat.domain.id)
@@ -1704,13 +1703,11 @@ class Statistics(models.Model):
stats['totaltransperc'] = int(100*stats['totaltrans']/stats['total'])
stats['totalfuzzyperc'] = int(100*stats['totalfuzzy']/stats['total'])
stats['totaluntransperc'] = int(100*stats['totaluntrans']/stats['total'])
- stats['categs'].keyOrder.sort()
+ stats['categs'] = OrderedDict(sorted(stats['categs'].items(), key=lambda t: t[0]))
for key, categ in stats['categs'].items():
categ['cattotal'] = categ['cattrans'] + categ['catfuzzy'] + categ['catuntrans']
if categ['cattotal'] > 0:
categ['cattransperc'] = int(100*categ['cattrans']/categ['cattotal'])
- # Sort modules
- categ['modules'].keyOrder.sort()
# Sort domains
for mod in categ['modules'].values():
for branch, doms in mod.items():
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]