[damned-lies] Convert archive-release command to Python 3
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Convert archive-release command to Python 3
- Date: Sat, 25 Mar 2017 10:48:28 +0000 (UTC)
commit 792ec72308aa5cadce38ed9f9c4440c79d156a48
Author: Claude Paroz <claude 2xlibre net>
Date: Sat Mar 25 11:46:56 2017 +0100
Convert archive-release command to Python 3
stats/management/commands/archive-release.py | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/stats/management/commands/archive-release.py b/stats/management/commands/archive-release.py
index 1d2a30d..160457d 100644
--- a/stats/management/commands/archive-release.py
+++ b/stats/management/commands/archive-release.py
@@ -1,5 +1,6 @@
import csv
-import StringIO
+from io import StringIO
+
from django.core.management.base import BaseCommand, CommandError
from stats.models import Release, Statistics
@@ -17,18 +18,20 @@ class Command(BaseCommand):
except Release.DoesNotExist:
raise CommandError("The release name '%s' is not known.\n" % options['release'])
- out = StringIO.StringIO()
+ out = StringIO()
headers = ['Module', 'Branch', 'Domain', 'Language', 'Translated', 'Fuzzy', 'Untranslated']
writer = csv.DictWriter(out, headers)
header = dict(zip(headers, headers))
writer.writerow(header)
- stats = Statistics.objects.filter(branch__category__release=release,
language__isnull=False).select_related('branch__module', 'domain', 'language')
+ stats = Statistics.objects.filter(
+ branch__category__release=release, language__isnull=False
+ ).select_related('branch__module', 'domain', 'language')
for stat in stats:
row = {
- 'Module': stat.branch.module.name.encode('utf-8'),
- 'Branch': stat.branch.name.encode('utf-8'),
- 'Domain': stat.domain.name.encode('utf-8'),
+ 'Module': stat.branch.module.name,
+ 'Branch': stat.branch.name,
+ 'Domain': stat.domain.name,
'Language': stat.language.locale,
'Translated': stat.translated(),
'Fuzzy': stat.fuzzy(),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]