damned-lies r1163 - in trunk: . languages stats templates/languages
- From: claudep svn gnome org
- To: svn-commits-list gnome org
- Subject: damned-lies r1163 - in trunk: . languages stats templates/languages
- Date: Wed, 12 Nov 2008 20:22:14 +0000 (UTC)
Author: claudep
Date: Wed Nov 12 20:22:14 2008
New Revision: 1163
URL: http://svn.gnome.org/viewvc/damned-lies?rev=1163&view=rev
Log:
2008-11-12 Claude Paroz <claude 2xlibre net>
* languages/urls.py: Add url corresponding to tarball.
* languages/views.py: Add view to get tarball.
* stats/models.py: get_lang_files function to get all po/pot files for a
release and a language (doc/ui separated).
* templates/languages/language_release_stats.html: Add a link to download
all po files (ui/doc).
Fixes #114122.
Modified:
trunk/ChangeLog
trunk/languages/urls.py
trunk/languages/views.py
trunk/stats/models.py
trunk/templates/languages/language_release_stats.html
Modified: trunk/languages/urls.py
==============================================================================
--- trunk/languages/urls.py (original)
+++ trunk/languages/urls.py Wed Nov 12 20:22:14 2008
@@ -2,6 +2,7 @@
urlpatterns = patterns('',
url(r'^$', 'languages.views.languages', name='languages'),
- url(r'(?P<locale>[\w\- ]+)/(?P<release_name>[\w-]+)/$', 'languages.views.language_release', name='language_release'),
- url(r'(?P<team_slug>[\w\- ]+)/$', 'teams.views.team', name='team_slug'),
+ url(r'^(?P<locale>[\w\- ]+)/(?P<release_name>[\w-]+)/$', 'languages.views.language_release', name='language_release'),
+ (r'^(?P<locale>[\w\- ]+)/(?P<release_name>[\w-]+)/(?P<dtype>(ui|doc)+).tar.gz$', 'languages.views.language_release_tar'),
+ url(r'^(?P<team_slug>[\w\- ]+)/$', 'teams.views.team', name='team_slug'),
)
Modified: trunk/languages/views.py
==============================================================================
--- trunk/languages/views.py (original)
+++ trunk/languages/views.py Wed Nov 12 20:22:14 2008
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2008 StÃphane Raimbault <stephane raimbault gmail com>
+# Copyright (c) 2008 Claude Paroz <claude 2xlibre net>
#
# This file is part of Damned Lies.
#
@@ -18,7 +19,12 @@
# along with Damned Lies; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+import os
+import tarfile
+from datetime import datetime
from django.shortcuts import render_to_response
+from django.http import HttpResponseRedirect
+from stats.conf import settings
from common import utils
from languages.models import Language
from stats.models import Release
@@ -42,3 +48,23 @@
'stats': stats
}
return render_to_response('languages/language_release.html', context)
+
+def language_release_tar(request, locale, release_name, dtype):
+ release = Release.objects.get(name=release_name)
+ language = Language.objects.get(locale=locale)
+ last_modif, file_list = release.get_lang_files(language, dtype)
+
+ tar_filename = '%s.%s.tar.gz' % (release.name, language.locale)
+ tar_directory = os.path.join(settings.POTDIR, 'tar')
+ if not os.access(tar_directory, os.R_OK):
+ os.mkdir(tar_directory)
+ tar_path = os.path.join(tar_directory, tar_filename)
+ if not os.access(tar_path, os.R_OK) or last_modif > datetime.fromtimestamp(os.path.getmtime(tar_path)):
+ # Create a new tar file
+ tar_file = tarfile.open(tar_path, 'w:gz')
+ for f in file_list:
+ tar_file.add(f, os.path.basename(f))
+ tar_file.close()
+
+ return HttpResponseRedirect("/POT/tar/%s" % tar_filename)
+
Modified: trunk/stats/models.py
==============================================================================
--- trunk/stats/models.py (original)
+++ trunk/stats/models.py Wed Nov 12 20:22:14 2008
@@ -665,8 +665,8 @@
# Sorted by module to allow grouping ('fake' stats)
pot_stats = Statistics.objects.filter(language=None, branch__releases=self).order_by('domain__module__id', 'domain__dtype')
- stats = {'doc':{'totaltrans':0, 'totalfuzzy':0, 'totaluntrans':0, 'categs':{}, 'all_errors':[]},
- 'ui':{'totaltrans':0, 'totalfuzzy':0, 'totaluntrans':0, 'categs':{}, 'all_errors':[]}
+ stats = {'doc':{'dtype':'doc', 'totaltrans':0, 'totalfuzzy':0, 'totaluntrans':0, 'categs':{}, 'all_errors':[]},
+ 'ui':{'dtype':'ui', 'totaltrans':0, 'totalfuzzy':0, 'totaluntrans':0, 'categs':{}, 'all_errors':[]}
}
for stat in pot_stats:
dtype = stat.domain.dtype
@@ -738,6 +738,26 @@
stats[dtype]['all_errors'].sort()
return stats
+ def get_lang_files(self, lang, dtype):
+ """ Return a list of all po files of a lang for this release, preceded by the more recent modification date
+ It uses the POT file if there is no po for a module """
+ pot_stats = Statistics.objects.filter(language=None, branch__releases=self, domain__dtype=dtype)
+ po_stats = Statistics.objects.filter(language=lang, branch__releases=self, domain__dtype=dtype)
+ lang_files = []
+ last_modif_date = datetime(1970, 01, 01)
+ # Create list of files
+ for stat in pot_stats:
+ if stat.date > last_modif_date:
+ last_modif_date = stat.date
+ try:
+ lang_stat = po_stats.get(branch = stat.branch, domain = stat.domain)
+ except Statistics.DoesNotExist:
+ lang_stat = stat
+ file_path = lang_stat.po_path()
+ if os.access(file_path, os.R_OK):
+ lang_files.append(file_path)
+ return last_modif_date, lang_files
+
CATEGORY_CHOICES = (
('default', 'Default'),
Modified: trunk/templates/languages/language_release_stats.html
==============================================================================
--- trunk/templates/languages/language_release_stats.html (original)
+++ trunk/templates/languages/language_release_stats.html Wed Nov 12 20:22:14 2008
@@ -83,3 +83,6 @@
{% endfor %}
</ul>
{% endif %}
+<hr />
+<p><a href="{% url languages.views.language_release_tar locale=language.locale release_name=release.name dtype=modstats.dtype %}"><img src="/media/img/download.png" /> {% trans "Download all po files" %}</a></p>
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]