[damned-lies] White spaces cleanup in all Python files
- From: Stéphane Raimbault <stephaner src gnome org>
- To: svn-commits-list gnome org
- Subject: [damned-lies] White spaces cleanup in all Python files
- Date: Thu, 21 May 2009 11:04:47 -0400 (EDT)
commit 124e39ca1e2c233df7e16b78d4a6462ab125ee14
Author: Stéphane Raimbault <stephane raimbault gmail com>
Date: Thu May 21 17:02:58 2009 +0200
White spaces cleanup in all Python files
- removed trailing spaces
- removed spaces on empty line
- removed empty lines at EOF
- potdiff.py is executable
---
common/templatetags/list_to_columns.py | 11 +-
common/utils.py | 4 +-
common/views.py | 3 +-
languages/models.py | 10 +-
languages/views.py | 4 +-
people/forms.py | 6 +-
people/models.py | 8 +-
people/urls.py | 1 -
people/views.py | 5 +-
settings_sample.py | 4 +-
stats/admin.py | 2 +-
stats/forms.py | 3 +-
stats/management/commands/compile-trans.py | 5 +-
stats/management/commands/copy-release.py | 9 +-
stats/management/commands/migrate-to-git.py | 9 +-
stats/management/commands/update-stats.py | 11 +-
stats/management/commands/update-trans.py | 24 ++--
stats/models.py | 201 +++++++++++++--------------
stats/potdiff.py | 5 +-
stats/signals.py | 1 -
stats/templatetags/stats_extras.py | 6 +-
stats/tests/__init__.py | 21 ++--
stats/utils.py | 30 ++--
stats/views.py | 8 +-
teams/forms.py | 2 +-
teams/models.py | 23 ++--
teams/urls.py | 2 +-
teams/views.py | 7 +-
urls.py | 2 +-
vertimus/feeds.py | 10 +-
vertimus/forms.py | 7 +-
vertimus/views.py | 14 +-
32 files changed, 220 insertions(+), 238 deletions(-)
diff --git a/common/templatetags/list_to_columns.py b/common/templatetags/list_to_columns.py
index dfb4f2e..c1f41a0 100644
--- a/common/templatetags/list_to_columns.py
+++ b/common/templatetags/list_to_columns.py
@@ -19,9 +19,8 @@
# along with Damned Lies; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
from django import template
-
+
register = template.Library()
class SplitListNode(template.Node):
@@ -31,10 +30,10 @@ class SplitListNode(template.Node):
self.new_list = new_list
def split_seq(self, list, cols=2):
- start = 0
- for i in xrange(cols):
- stop = start + len(list[i::cols])
- yield list[start:stop]
+ start = 0
+ for i in xrange(cols):
+ stop = start + len(list[i::cols])
+ yield list[start:stop]
start = stop
def render(self, context):
diff --git a/common/utils.py b/common/utils.py
index f68db88..5af08ca 100644
--- a/common/utils.py
+++ b/common/utils.py
@@ -97,7 +97,7 @@ def imerge_sorted_by_field(object_list1, object_list2, field):
[6, 5, 4, 4, 4, 2, 1, 1]
"""
import operator
-
+
if field is not None and field[0] == '-':
# Reverse the sort order
field = field[1:]
@@ -106,7 +106,7 @@ def imerge_sorted_by_field(object_list1, object_list2, field):
op = operator.lt
iter1, iter2 = iter(object_list1), iter(object_list2)
-
+
# Too many try/except couples to my taste but I don't know how to filter the
# StopIteration to find the source.
diff --git a/common/views.py b/common/views.py
index f5d0950..51e53aa 100644
--- a/common/views.py
+++ b/common/views.py
@@ -27,7 +27,7 @@ from django.contrib.auth import login, authenticate, logout
from django.conf import settings
from people.models import Person
from teams.models import Role
-from people.forms import RegistrationForm
+from people.forms import RegistrationForm
def index(request):
@@ -115,4 +115,3 @@ def activate_account(request, key):
person.activate()
Person.clean_unactivated_accounts()
return site_login(request, msgs=[_("Your account has been activated.")])
-
diff --git a/languages/models.py b/languages/models.py
index 6106eba..02438b4 100644
--- a/languages/models.py
+++ b/languages/models.py
@@ -19,24 +19,24 @@ class Language(models.Model):
return _(self.name)
else:
return self.locale
-
+
def bugs_url_enter(self):
return "http://bugzilla.gnome.org/enter_bug.cgi?product=l10n&component=%s%%20[%s]" % (self.name, self.locale)
-
+
def bugs_url_show(self):
- return "http://bugzilla.gnome.org/buglist.cgi?product=l10n&component=%s%%20[%s]&bug_status=NEW&bug_status=REOPENED&bug_status=ASSIGNED&bug_status=UNCONFIRMED" % (self.name, self.locale)
+ return "http://bugzilla.gnome.org/buglist.cgi?product=l10n&component=%s%%20[%s]&bug_status=NEW&bug_status=REOPENED&bug_status=ASSIGNED&bug_status=UNCONFIRMED" % (self.name, self.locale)
def get_release_stats(self):
# FIXME Here be dragons
""" Get summary stats for all releases """
from stats.models import Release
-
+
releases = Release.objects.all().order_by('status', '-name')
stats = []
for rel in releases:
stats.append(rel.total_for_lang(self))
return stats
-
+
def get_team_url(self):
if self.team:
return self.team.get_absolute_url()
diff --git a/languages/views.py b/languages/views.py
index 292c9f8..5fd0bc0 100644
--- a/languages/views.py
+++ b/languages/views.py
@@ -90,7 +90,7 @@ def language_release_tar(request, locale, release_name, dtype):
for f in file_list:
tar_file.add(f, os.path.basename(f))
tar_file.close()
-
+
return HttpResponseRedirect("/POT/tar/%s" % tar_filename)
def language_release_xml(request, locale, release_name):
@@ -141,7 +141,7 @@ def language_release_xml(request, locale, release_name):
content += "</module>"
except:
pass
-
+
if catname != 'default':
content += "</category>"
content += "</stats>"
diff --git a/people/forms.py b/people/forms.py
index abf2803..e0e9cb9 100644
--- a/people/forms.py
+++ b/people/forms.py
@@ -21,7 +21,7 @@ class RegistrationForm(forms.Form):
help_text=ugettext_lazy(u'At least 7 characters'))
password2 = forms.CharField(widget=forms.PasswordInput(render_value=False),
label=ugettext_lazy(u'Confirm password:'), required=False)
-
+
def clean_username(self):
""" Validate the username (correctness and uniqueness)"""
try:
@@ -37,7 +37,7 @@ class RegistrationForm(forms.Form):
openid_url = cleaned_data.get('openid_url')
if not password1 and not openid_url:
raise forms.ValidationError(_(u'You must either provide an OpenID or a password'))
-
+
if password1 and password1 != password2:
raise forms.ValidationError(_(u'The passwords do not match'))
return cleaned_data
@@ -64,7 +64,7 @@ class RegistrationForm(forms.Form):
current_site = Site.objects.get_current()
subject = settings.EMAIL_SUBJECT_PREFIX + _(u'Account activation')
message = _(u"This is a confirmation that your registration on %s succeeded. To activate your account, please click on the link below or copy and paste it in a browser.") % current_site.name
- message += "\n\nhttp://%s%s\n\n" % (current_site.domain, str(reverse("register_activation", kwargs={'key': activation_key})))
+ message += "\n\nhttp://%s%s\n\n" % (current_site.domain, str(reverse("register_activation", kwargs={'key': activation_key})))
message += _(u"Administrators of %s" % current_site.name)
send_mail(subject, message, settings.DEFAULT_FROM_EMAIL,
diff --git a/people/models.py b/people/models.py
index 94f7765..eb46f63 100644
--- a/people/models.py
+++ b/people/models.py
@@ -50,7 +50,7 @@ class Person(User):
@classmethod
def clean_unactivated_accounts(cls):
- accounts = cls.objects.filter(activation_key__isnull=False,
+ accounts = cls.objects.filter(activation_key__isnull=False,
date_joined__lt=(datetime.datetime.now()-datetime.timedelta(days=10))).exclude(activation_key='')
for account in accounts:
account.delete()
@@ -60,12 +60,12 @@ class Person(User):
self.password = None
self.set_unusable_password()
super(User, self).save()
-
+
def activate(self):
self.activation_key = None
self.is_active = True
self.save()
-
+
def no_spam_email(self):
return obfuscate_email(self.email)
@@ -96,7 +96,7 @@ class Person(User):
return True
except:
return False
-
+
def is_committer(self, team):
try:
self.role_set.get(team__id=team.id, role__in=['committer', 'coordinator'])
diff --git a/people/urls.py b/people/urls.py
index b19889c..94948c7 100644
--- a/people/urls.py
+++ b/people/urls.py
@@ -24,4 +24,3 @@ urlpatterns = patterns('people.views',
urlpatterns += patterns('django.views.generic.list_detail',
url(r'^$', 'object_list', dict(info_dict_list), name='persons-view'),
)
-
diff --git a/people/views.py b/people/views.py
index 82cc7ea..b91b965 100644
--- a/people/views.py
+++ b/people/views.py
@@ -99,7 +99,7 @@ def person_team_join(request):
context_instance = RequestContext(request)
transaction.commit()
- return render_to_response('people/person_team_join_form.html', context,
+ return render_to_response('people/person_team_join_form.html', context,
context_instance=context_instance)
@login_required
@@ -114,7 +114,7 @@ def person_team_leave(request, team_slug):
# Message no i18n'ed, should never happen under normal conditions
person.message_set.create(message="You are not a member of this team.")
# redirect to normal person detail
- return HttpResponseRedirect(urlresolvers.reverse('person-username-view',
+ return HttpResponseRedirect(urlresolvers.reverse('person-username-view',
args=(person.username,)))
@login_required
@@ -138,4 +138,3 @@ def person_password_change(request):
}
return render_to_response('people/person_password_change_form.html', context,
context_instance=RequestContext(request))
-
diff --git a/settings_sample.py b/settings_sample.py
index fa81bea..4447e20 100644
--- a/settings_sample.py
+++ b/settings_sample.py
@@ -33,7 +33,7 @@ DATABASE_PORT = '' # Set to empty string for default. Not used with
# 'read_default_file': '/etc/mysql/my.cnf',
# 'init_command': 'SET storage_engine=INNODB'
# }
-#
+#
# Please refer to the README file to create an UTF-8 database with MySQL.
EMAIL_HOST = 'localhost'
@@ -140,5 +140,5 @@ if USE_DJANGO_EVOLUTION:
INSTALLED_APPS += ('django_evolution',)
if USE_DEBUG_TOOLBAR:
- MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
+ MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
INSTALLED_APPS += ('debug_toolbar',)
diff --git a/stats/admin.py b/stats/admin.py
index dd684c7..4601252 100644
--- a/stats/admin.py
+++ b/stats/admin.py
@@ -36,7 +36,7 @@ class ModuleAdmin(admin.ModelAdmin):
fieldsets = (
(None, {
'fields': (('name','description'),
- 'homepage', 'comment',
+ 'homepage', 'comment',
('bugs_base', 'bugs_product', 'bugs_component'),
('vcs_type', 'vcs_root', 'vcs_web'),
'maintainers')
diff --git a/stats/forms.py b/stats/forms.py
index fadd6a9..53449fd 100644
--- a/stats/forms.py
+++ b/stats/forms.py
@@ -28,7 +28,7 @@ class ModuleBranchForm(forms.Form):
label=branch.name)
self.fields[branch.name+'_cat'] = forms.ChoiceField(choices=CATEGORY_CHOICES)
self.branch_fields.append((branch.name, branch.name+'_cat'))
-
+
self.fields['new_branch'] = forms.CharField(required=False)
self.fields['new_branch_release'] = ReleaseField(queryset=Release.objects.all())
self.fields['new_branch_category'] = forms.ChoiceField(choices=CATEGORY_CHOICES)
@@ -36,4 +36,3 @@ class ModuleBranchForm(forms.Form):
def get_branches(self):
for rel_field, cat_field in self.branch_fields:
yield (self[rel_field], self[cat_field])
-
diff --git a/stats/management/commands/compile-trans.py b/stats/management/commands/compile-trans.py
index 3f6099b..f8b3cf1 100644
--- a/stats/management/commands/compile-trans.py
+++ b/stats/management/commands/compile-trans.py
@@ -6,7 +6,7 @@ import shutil
class Command(NoArgsCommand):
help = "Compile translations of djamnedlies"
args = ""
-
+
output_transaction = False
def handle(self, **options):
@@ -20,7 +20,6 @@ class Command(NoArgsCommand):
if not os.path.isdir(localedir):
os.makedirs(localedir)
shutil.copy(os.path.join(podir, pofile), os.path.join(localedir, 'django.po'))
-
+
# Run compilemessages -l ll
compilemessages.compile_messages()
-
diff --git a/stats/management/commands/copy-release.py b/stats/management/commands/copy-release.py
index a30a227..69d4fc0 100644
--- a/stats/management/commands/copy-release.py
+++ b/stats/management/commands/copy-release.py
@@ -24,7 +24,7 @@ from stats.models import Release, Category, Module
class Command(BaseCommand):
help = "Copy an existing release and use trunk branches"
args = "RELEASE_TO_COPY, NEW_RELEASE"
-
+
output_transaction = False
def handle(self, *args, **options):
@@ -35,10 +35,10 @@ class Command(BaseCommand):
rel_to_copy = Release.objects.get(name=args[0])
except:
raise CommandError("No release named '%s'" % args[0])
-
+
new_rel = Release(name=args[1], description=args[1], string_frozen=False, status=rel_to_copy.status)
new_rel.save()
-
+
for cat in rel_to_copy.category_set.all():
if not cat.branch.is_head():
mod = Module.objects.get(pk=cat.branch.module.id)
@@ -46,6 +46,5 @@ class Command(BaseCommand):
else:
branch = cat.branch
new_rel.category_set.add(Category(release=new_rel, branch=branch, name=cat.name))
-
- print "New release '%s' created" % args[1]
+ print "New release '%s' created" % args[1]
diff --git a/stats/management/commands/migrate-to-git.py b/stats/management/commands/migrate-to-git.py
index eb14832..ece9b52 100644
--- a/stats/management/commands/migrate-to-git.py
+++ b/stats/management/commands/migrate-to-git.py
@@ -15,12 +15,12 @@ class Command(BaseCommand):
old_branch_dirs = []
for branch in module.branch_set.all():
old_branch_dirs.append(branch.co_path())
-
+
module.vcs_type = "git"
module.vcs_root = "git://git.gnome.org/%s" % module.name
module.vcs_web = "http://git.gnome.org/cgit/%s/" % module.name
module.save()
-
+
# Checkout new git repo with master branch
head_branch = Branch.objects.get(module__name=module.name, name='HEAD')
head_branch.name = "master"
@@ -29,7 +29,7 @@ class Command(BaseCommand):
except Exception, e:
print "Unable to save master branch for module '%s': %s" % (module.name, e)
continue
-
+
for branch in module.branch_set.exclude(name='master'):
# Checkout branch (other than master)
cmd = "cd \"%(localdir)s\" && git checkout --track -b %(branch)s origin/%(branch)s" % {
@@ -42,8 +42,7 @@ class Command(BaseCommand):
print "Unable to checkout branch '%s' of module '%s': %s" % (branch.name, module.name, e)
continue
branch.update_stats(force=False)
-
+
# delete old checkouts
for branch_dir in old_branch_dirs:
shutil.rmtree(branch_dir)
-
diff --git a/stats/management/commands/update-stats.py b/stats/management/commands/update-stats.py
index 993fa6e..29421db 100644
--- a/stats/management/commands/update-stats.py
+++ b/stats/management/commands/update-stats.py
@@ -8,13 +8,13 @@ from stats.models import Module, Branch
class Command(BaseCommand):
help = "Update statistics about po file"
args = "[MODULE [BRANCH]]"
-
+
option_list = BaseCommand.option_list + (
make_option('--force', action='store_true', dest='force', default=False,
help="force statistics generation, even if files didn't change"),
make_option('--non-gnome', action='store_true', dest='non-gnome', default=False,
help="generate statistics for non-gnome modules (externally hosted)"),
- )
+ )
output_transaction = False
@@ -41,7 +41,7 @@ class Command(BaseCommand):
print >> sys.stderr, "Error during updating, mail sent to admins"
finally:
self.release_lock_for_module(module_arg, branch_arg)
-
+
elif len(args) == 1:
# Update all branches of a module
module_arg = args[0]
@@ -51,7 +51,7 @@ class Command(BaseCommand):
try:
self.get_lock_for_module(module_arg, branch.name)
branch.update_stats(options['force'])
- except:
+ except:
print "Error while updating stats for %s (branch '%s')" % (module_arg, branch.name)
finally:
self.release_lock_for_module(module_arg, branch.name)
@@ -74,7 +74,7 @@ class Command(BaseCommand):
self.release_lock_for_module(mod.name, branch.name)
return "Update completed."
-
+
# Weird things happen when multiple updates run in parallel for the same module
# We use filesystem directories creation/deletion to act as global lock mecanism
def get_lock_for_module(self, module_name, branch_name):
@@ -90,4 +90,3 @@ class Command(BaseCommand):
def release_lock_for_module(self, module_name, branch_name):
dirpath = os.path.join("/tmp", "updating-%s" % (module_name,))
os.rmdir(dirpath)
-
diff --git a/stats/management/commands/update-trans.py b/stats/management/commands/update-trans.py
index 1498902..27ccc90 100644
--- a/stats/management/commands/update-trans.py
+++ b/stats/management/commands/update-trans.py
@@ -9,11 +9,11 @@ from django.conf import settings
class Command(BaseCommand):
help = "Update translations of djamnedlies ('en' is a special case, and generate damned-lies.pot)"
args = "LANG_CODE"
-
+
#option_list = BaseCommand.option_list + (
# make_option('--pot', action='store_true', dest='pot', default=False,
# help="create a pot file"),
- #)
+ #)
output_transaction = False
@@ -33,15 +33,15 @@ class Command(BaseCommand):
shutil.copy(pofile, os.path.join(localedir, 'django.po'))
else:
pofile = os.path.join(podir, 'damned-lies.pot')
-
+
# Extract DB translatable strings into database-content.py
dbfile = os.path.join(os.path.abspath('.'), 'database-content.py')
f=open(dbfile, 'w')
- query = """SELECT description FROM team UNION
- SELECT name from language WHERE name <> locale UNION
- SELECT description FROM domain UNION
- SELECT description FROM module WHERE description <> name UNION
- SELECT comment FROM module WHERE comment IS NOT NULL AND comment <> '' UNION
+ query = """SELECT description FROM team UNION
+ SELECT name from language WHERE name <> locale UNION
+ SELECT description FROM domain UNION
+ SELECT description FROM module WHERE description <> name UNION
+ SELECT comment FROM module WHERE comment IS NOT NULL AND comment <> '' UNION
SELECT description FROM "release" """
cursor = connection.cursor()
if settings.DATABASE_ENGINE == 'mysql':
@@ -54,13 +54,11 @@ class Command(BaseCommand):
# Run makemessages -l ll
makemessages.make_messages(lang_code, verbosity=2, extensions=['.html'])
-
+
# Delete database-content.py
os.unlink(dbfile)
-
+
# Copy locale/ll/LC_MESSAGES/django.po to po/ll.po
shutil.copy(os.path.join(localedir, 'django.po'), pofile)
-
- return "po file for language '%s' updated." % lang_code
-
+ return "po file for language '%s' updated." % lang_code
diff --git a/stats/models.py b/stats/models.py
index e66272f..787f2e3 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -33,8 +33,8 @@ from people.models import Person
from languages.models import Language
VCS_TYPE_CHOICES = (
- ('cvs', 'CVS'),
- ('svn', 'Subversion'),
+ ('cvs', 'CVS'),
+ ('svn', 'Subversion'),
('git', 'Git'),
('hg', 'Mercurial'),
('bzr', 'Bazaar')
@@ -58,17 +58,17 @@ class Module(models.Model):
# URLField is too restrictive for vcs_root
vcs_root = models.CharField(max_length=200)
vcs_web = models.URLField()
-
+
maintainers = models.ManyToManyField(Person, db_table='module_maintainer',
related_name='maintains_modules', blank=True)
class Meta:
db_table = 'module'
ordering = ('name',)
-
+
def __unicode__(self):
return self.name
-
+
@models.permalink
def get_absolute_url(self):
return ('stats.views.module', [self.name])
@@ -82,11 +82,11 @@ class Module(models.Model):
return _(self.description)
else:
return self.name
-
+
def has_standard_vcs(self):
""" This function checks if the module is hosted in the standard VCS of the project """
return re.search(settings.VCS_HOME_REGEX, self.vcs_root) is not None
-
+
def get_bugs_i18n_url(self):
if self.bugs_base.find("bugzilla") != -1 or self.bugs_base.find("freedesktop") != -1:
return utils.url_join(self.bugs_base,
@@ -101,13 +101,13 @@ class Module(models.Model):
else:
return utils.url_join(self.bugs_base, "enter_bug.cgi?product=%s" % (self.bugs_product,))
else:
- return self.bugs_base
-
+ return self.bugs_base
+
def get_branches(self, reverse=False):
branches = list(self.branch_set.all())
branches.sort(reverse=reverse)
return branches
-
+
def get_head_branch(self):
""" Returns the HEAD (trunk, master, ...) branch of the module """
branch = self.branch_set.filter(name__in = BRANCH_HEAD_NAMES)
@@ -116,9 +116,9 @@ class Module(models.Model):
return branch[0]
else:
return None
-
+
def can_edit_branches(self, user):
- """ Returns True for superusers, users with adequate permissions or maintainers of the module """
+ """ Returns True for superusers, users with adequate permissions or maintainers of the module """
if user.is_superuser or \
user.has_perms(['stats.delete_branch', 'stats.add_branch', 'stats.change_branch']) or \
user.username in [ p.username for p in self.maintainers.all() ]:
@@ -142,7 +142,7 @@ class Branch(models.Model):
vcs_subpath = models.CharField(max_length=50, null=True, blank=True)
module = models.ForeignKey(Module)
# 'releases' is the backward relation name from Release model
-
+
# May be set to False by test suite
checkout_on_creation = True
@@ -167,7 +167,7 @@ class Branch(models.Model):
# The update command is launched asynchronously in a separate thread
upd_thread = threading.Thread(target=self.update_stats, kwargs={'force':True})
upd_thread.start()
-
+
def delete(self):
# Remove the repo checkout
localdir = os.path.join(settings.SCRATCHDIR, self.module.vcs_type, self.module.name + "." + self.name)
@@ -190,7 +190,7 @@ class Branch(models.Model):
def has_string_frozen(self):
""" Returns true if the branch is contained in at least one string frozen release """
return self.releases.filter(string_frozen=True).count() and True or False
-
+
def get_vcs_url(self):
if self.module.vcs_type in ('hg', 'git'):
return self.module.vcs_root
@@ -221,7 +221,7 @@ class Branch(models.Model):
else:
branch_dir = self.module.name + "." + self.name
return os.path.join(settings.SCRATCHDIR, self.module.vcs_type, branch_dir)
-
+
def output_dir(self, dom_type):
""" Directory where generated pot and po files are written on local system """
subdir = {'ui': '', 'doc': 'docs'}[dom_type]
@@ -229,7 +229,7 @@ class Branch(models.Model):
if not os.path.isdir(dirname):
os.makedirs(dirname)
return dirname
-
+
def get_stats(self, typ, mandatory_langs=[]):
""" Get statistics list of type typ ('ui' or 'doc'), in a dict of lists, key is domain.name (POT in 1st position)
stats = {'po': [potstat, polang1, polang2, ...],
@@ -256,7 +256,7 @@ class Branch(models.Model):
for key, doms in stats.items():
doms.sort(self.compare_stats)
return stats
-
+
def compare_stats(self, a, b):
""" Sort stats, pot first, then translated (desc), then language name """
if not a.language:
@@ -267,8 +267,8 @@ class Branch(models.Model):
res = -cmp(a.translated, b.translated)
if not res:
res = cmp(a.get_lang(), b.get_lang())
- return res
-
+ return res
+
def get_doc_stats(self, mandatory_langs=[]):
if not self._doc_stats:
self._doc_stats = self.get_stats('doc', mandatory_langs)
@@ -278,7 +278,7 @@ class Branch(models.Model):
if not self._ui_stats:
self._ui_stats = self.get_stats('ui', mandatory_langs)
return self._ui_stats
-
+
def update_stats(self, force, checkout=True):
""" Update statistics for all po files from the branch """
if checkout:
@@ -293,13 +293,13 @@ class Branch(models.Model):
# TODO: should check if existing stats, and delete (archive) them in this case
continue
errors = []
-
+
# 2. Pre-check, if available (intltool-update -m)
# **************************
if dom.dtype == 'ui' and not dom.pot_method:
# Run intltool-update -m to check for some errors
errors.extend(utils.check_potfiles(domain_path))
-
+
# 3. Generate a fresh pot file
# ****************************
if dom.dtype == 'ui':
@@ -312,9 +312,9 @@ class Branch(models.Model):
doclinguas = utils.read_makefile_variable(domain_path, "DOC_LINGUAS").split()
else:
print >> sys.stderr, "Unknown domain type '%s', ignoring domain '%s'" % (dom.dtype, dom.name)
- continue
+ continue
errors.extend(errs)
-
+
# Prepare statistics object
try:
stat = Statistics.objects.get(language=None, branch=self, domain=dom)
@@ -344,10 +344,10 @@ class Branch(models.Model):
changed_status, diff = utils.pot_diff_status(previous_pot, potfile)
if string_frozen and dom.dtype == 'ui' and changed_status == utils.CHANGED_WITH_ADDITIONS:
utils.notify_list("%s.%s" % (self.module.name, self.name), diff)
-
+
if changed_status != utils.NOT_CHANGED:
signals.pot_has_changed.send(sender=self, potfile=potfile, branch=self, domain=dom)
-
+
# 5. Generate pot stats and update DB
# ***********************************
pot_stats = utils.po_file_stats(potfile, False)
@@ -360,7 +360,7 @@ class Branch(models.Model):
stat.date = datetime.now()
stat.save()
stat.set_errors(errors)
-
+
# 6. Update language po files and update DB
# *****************************************
command = "msgmerge --previous -o %(outpo)s %(pofile)s %(potfile)s"
@@ -415,8 +415,8 @@ class Branch(models.Model):
fuzzy = int(langstats['fuzzy']), untranslated = int(langstats['untranslated']))
stat.save()
for err in langstats['errors']:
- stat.information_set.add(Information(type=err[0], description=err[1]))
-
+ stat.information_set.add(Information(type=err[0], description=err[1]))
+
def get_lang_files(self, domain, dom_path):
""" Returns a list of language files on filesystem, as tuple (lang, lang_file) -> lang_file with complete path """
flist = []
@@ -434,7 +434,7 @@ class Branch(models.Model):
if os.path.isfile(pofile):
flist.append((d, pofile))
return flist
-
+
def checkout(self):
""" Do a checkout or an update of the VCS files """
module_name = self.module.name
@@ -451,7 +451,7 @@ class Branch(models.Model):
try: os.makedirs(localroot)
except: pass
-
+
commandList = []
if branch_exists:
# Path exists, update repos
@@ -526,7 +526,7 @@ class Branch(models.Model):
"bzrpath" : vcs_path,
"dir" : moduledir,
})
-
+
# Run command(s)
if settings.DEBUG:
print >>sys.stdout, "Checking '%s.%s' out to '%s'..." % (module_name, self.name, modulepath)
@@ -617,7 +617,7 @@ class Domain(models.Model):
dtype = models.CharField(max_length=5, choices=DOMAIN_TYPE_CHOICES, default='ui')
directory = models.CharField(max_length=50)
# The pot_method is a command who should produce a potfile in the po directory of
- # the domain, named <potbase()>.pot (e.g. /po/gnucash.pot). If blank, method is
+ # the domain, named <potbase()>.pot (e.g. /po/gnucash.pot). If blank, method is
# intltool for UI and gnome-doc-utils for DOC
pot_method = models.CharField(max_length=50, null=True, blank=True)
@@ -635,16 +635,16 @@ class Domain(models.Model):
return "%s-help" % self.module.name
else:
return self.name
-
+
def get_description(self):
if self.description:
return _(self.description)
else:
return self.potbase()
-
+
def generate_pot_file(self, vcs_path):
""" Return the pot file generated, and the error if any """
-
+
pot_command = self.pot_method
podir = vcs_path
env = None
@@ -671,7 +671,7 @@ class Domain(models.Model):
)
else:
return potfile, ()
-
+
RELEASE_STATUS_CHOICES = (
('official', 'Official'),
('unofficial', 'Unofficial'),
@@ -704,18 +704,18 @@ class Release(models.Model):
LOCALE, NAME, REL_ID, TRANS, FUZZY, UNTRANS = 0, 1, 2, 3, 4, 5
query = """
SELECT language.locale, language.name, category.release_id,
- SUM(stat.translated),
+ SUM(stat.translated),
SUM(stat.fuzzy),
SUM(stat.untranslated)
FROM statistics AS stat
LEFT JOIN language
ON stat.language_id = language.id
- INNER JOIN domain
+ INNER JOIN domain
ON stat.domain_id = domain.id
- INNER JOIN branch
+ INNER JOIN branch
ON stat.branch_id = branch.id
- INNER JOIN category
- ON category.branch_id = branch.id
+ INNER JOIN category
+ ON category.branch_id = branch.id
WHERE domain.dtype = %%s
AND category.release_id IN (%s)
GROUP BY language_id, category.release_id
@@ -741,17 +741,17 @@ class Release(models.Model):
""" Returns the total number of strings in the release as a tuple (doc_total, ui_total) """
# Uses the special statistics record where language_id is NULL to compute the sum.
query = """
- SELECT domain.dtype,
+ SELECT domain.dtype,
SUM(stat.untranslated)
FROM statistics AS stat
- LEFT JOIN domain
+ LEFT JOIN domain
ON domain.id = stat.domain_id
LEFT JOIN branch AS br
ON br.id = stat.branch_id
LEFT JOIN category AS cat
ON cat.branch_id = br.id
LEFT JOIN "release" AS rel
- ON rel.id = cat.release_id
+ ON rel.id = cat.release_id
WHERE rel.id = %s
AND stat.language_id IS NULL
GROUP BY domain.dtype"""
@@ -767,24 +767,24 @@ class Release(models.Model):
elif row[0] == 'doc':
total_doc = row[1]
return (total_doc, total_ui)
-
+
def total_for_lang(self, lang):
""" Returns total translated/fuzzy/untranslated strings for a specific
language """
-
+
total_doc, total_ui = self.total_strings()
query = """
SELECT domain.dtype,
- SUM(stat.translated),
- SUM(stat.fuzzy)
+ SUM(stat.translated),
+ SUM(stat.fuzzy)
FROM statistics AS stat
- LEFT JOIN domain
+ LEFT JOIN domain
ON stat.domain_id = domain.id
- LEFT JOIN branch
+ LEFT JOIN branch
ON stat.branch_id = branch.id
- LEFT JOIN category
- ON category.branch_id = branch.id
- WHERE language_id = %s
+ LEFT JOIN category
+ ON category.branch_id = branch.id
+ WHERE language_id = %s
AND category.release_id = %s
GROUP BY domain.dtype"""
cursor = connection.cursor()
@@ -812,22 +812,22 @@ class Release(models.Model):
stats['docfuzzyperc'] = int(100*stats['docfuzzy']/total_doc)
stats['docuntransperc'] = int(100*stats['docuntrans']/total_doc)
return stats
-
+
def get_global_stats(self):
""" Get statistics for all languages in a release, grouped by language
Returns a sorted list: (language, doc_trans, doc_fuzzy,
doc_untrans, ui_trans, ui_fuzzy, ui_untrans) """
query = """
- SELECT MIN(lang.name),
- MIN(lang.locale),
- domain.dtype,
- SUM(stat.translated) AS trans,
+ SELECT MIN(lang.name),
+ MIN(lang.locale),
+ domain.dtype,
+ SUM(stat.translated) AS trans,
SUM(stat.fuzzy)
FROM statistics AS stat
- LEFT JOIN domain
+ LEFT JOIN domain
ON domain.id = stat.domain_id
- LEFT JOIN language AS lang
+ LEFT JOIN language AS lang
ON stat.language_id = lang.id
LEFT JOIN branch AS br
ON br.id = stat.branch_id
@@ -869,22 +869,22 @@ class Release(models.Model):
results = stats.values()
results.sort(self.compare_stats)
- return results
-
+ return results
+
def compare_stats(self, a, b):
res = cmp(b['ui_trans'], a['ui_trans'])
if not res:
res = cmp(b['doc_trans'], a['doc_trans'])
if not res:
res = cmp(b['lang_name'], a['lang_name'])
- return res
-
+ return res
+
def get_lang_stats(self, lang):
""" Get statistics for a specific language, producing the stats data structure
Used for displaying the language-release template """
-
+
stats = {'doc': Statistics.get_lang_stats_by_type(lang, 'doc', self),
- 'ui': Statistics.get_lang_stats_by_type(lang, 'ui', self),
+ 'ui': Statistics.get_lang_stats_by_type(lang, 'ui', self),
}
return stats
@@ -929,7 +929,7 @@ class Category(models.Model):
def __unicode__(self):
return "%s (%s, %s)" % (self.get_name_display(), self.release, self.branch)
-
+
@classmethod
def get_cat_name(cls, key):
for entry in CATEGORY_CHOICES:
@@ -941,7 +941,7 @@ class Statistics(models.Model):
branch = models.ForeignKey(Branch)
domain = models.ForeignKey(Domain)
language = models.ForeignKey(Language, null=True)
-
+
date = models.DateTimeField(auto_now_add=True)
translated = models.IntegerField(default=0)
fuzzy = models.IntegerField(default=0)
@@ -954,7 +954,7 @@ class Statistics(models.Model):
verbose_name = "statistics"
verbose_name_plural = verbose_name
unique_together = ('branch', 'domain', 'language')
-
+
def __init__(self, *args, **kwargs):
models.Model.__init__(self, *args, **kwargs)
self.figures = None
@@ -962,7 +962,7 @@ class Statistics(models.Model):
self.moddescription = None
self.partial_po = False # True if part of a multiple po module
self.info_list = []
-
+
def __unicode__(self):
""" String representation of the object """
return "%s (%s-%s) %s (%s)" % (self.branch.module.name, self.domain.dtype, self.domain.name,
@@ -970,19 +970,19 @@ class Statistics(models.Model):
def is_fake(self):
return False
-
+
def tr_percentage(self):
if self.pot_size() == 0:
return 0
else:
return int(100*self.translated/self.pot_size())
-
+
def fu_percentage(self):
if self.pot_size() == 0:
return 0
else:
return int(100*self.fuzzy/self.pot_size())
-
+
def un_percentage(self):
if self.pot_size() == 0:
return 0
@@ -991,35 +991,35 @@ class Statistics(models.Model):
def get_lang(self):
if self.language:
- return _("%(lang_name)s (%(lang_locale)s)") % {
+ return _("%(lang_name)s (%(lang_locale)s)") % {
'lang_name': _(self.language.name),
'lang_locale': self.language.locale
}
else:
return "pot file"
-
+
def module_name(self):
if not self.modname:
self.modname = self.branch.module.name
return self.modname
-
+
def module_description(self):
if not self.moddescription:
self.moddescription = self.branch.module.description or self.branch.module.name
return self.moddescription
-
+
def get_translationstat(self):
return "%d%% (%d/%d/%d)" % (self.tr_percentage(), self.translated, self.fuzzy, self.untranslated)
-
+
def filename(self, potfile=False):
if self.language and not potfile:
return "%s.%s.%s.po" % (self.domain.potbase(), self.branch.name, self.language.locale)
else:
return "%s.%s.pot" % (self.domain.potbase(), self.branch.name)
-
+
def pot_size(self):
return int(self.translated) + int(self.fuzzy) + int(self.untranslated)
-
+
def pot_text(self):
""" Return stat table header: 'POT file (n messages) - updated on ??-??-???? tz' """
msg_text = ungettext(u"%(count)s message", "%(count)s messages", self.pot_size()) % {'count': self.pot_size()}
@@ -1035,7 +1035,7 @@ class Statistics(models.Model):
text = _(u"POT file (%(messages)s) â?? %(updated)s") % \
{'messages': msg_text, 'updated': upd_text}
return text
-
+
def get_figures(self):
if self.figures is None and self.domain.dtype == 'doc':
self.figures = utils.get_fig_stats(self.po_path())
@@ -1046,11 +1046,11 @@ class Statistics(models.Model):
if os.path.exists(os.path.join(self.branch.co_path(), self.domain.directory, self.language.locale, fig['path'])):
fig['translated_file'] = True
return self.figures
-
+
def fig_count(self):
""" If stat of a document type, get the number of figures in the document """
return self.num_figures
-
+
def fig_stats(self):
stats = {'fuzzy':0, 'translated':0, 'total':0, 'prc':0}
for fig in self.get_figures():
@@ -1062,22 +1062,22 @@ class Statistics(models.Model):
if stats['total'] > 0:
stats['prc'] = 100*stats['translated']/stats['total']
return stats
-
+
def vcs_path(self):
""" Return the VCS path of file on remote vcs """
return utils.url_join(self.branch.get_vcs_url(), self.domain.directory)
-
+
def vcs_web_path(self):
""" Return the Web interface path of file on remote vcs """
return utils.url_join(self.branch.get_vcs_web_url(), self.domain.directory)
-
+
def po_path(self, potfile=False):
""" Return path of po file on local filesystem """
subdir = ""
if self.domain.dtype == "doc":
subdir = "docs"
return os.path.join(settings.POTDIR, self.module_name()+'.'+self.branch.name, subdir, self.filename(potfile))
-
+
def po_url(self, potfile=False):
""" Return URL of po file, e.g. for downloading the file """
subdir = ""
@@ -1118,7 +1118,7 @@ class Statistics(models.Model):
'catname': <catname>, # translated category name (see CATEGORY_CHOICES)
'cattotal': 0,
'cattrans': 0,
- 'catfuzzy': 0,
+ 'catfuzzy': 0,
'catuntrans': 0,
'cattransperc': 0,
'modules': { # This dict is converted to a sorted list at the end of stats computation
@@ -1136,7 +1136,7 @@ class Statistics(models.Model):
}
"""
from vertimus.models import StateDb, ActionDb # import here to prevent a circular dependency
-
+
stats = {'dtype':dtype, 'totaltrans':0, 'totalfuzzy':0, 'totaluntrans':0,
'totaltransperc': 0, 'totalfuzzyperc': 0, 'totaluntransperc': 0,
'categs':{}, 'all_errors':[]}
@@ -1155,7 +1155,7 @@ class Statistics(models.Model):
tr_stats_dict = dict([("%d-%d" % (st.branch.id, st.domain.id),st) for st in tr_stats])
infos_dict = Information.get_info_dict(lang)
-
+
# Prepare StateDb objects in a dict (with "branch_id-domain_id" as key), to save database queries later
vt_states = StateDb.objects.select_related('branch','domain')
if release:
@@ -1214,7 +1214,7 @@ class Statistics(models.Model):
stats['categs'][categdescr]['modules'][modname][branchname][0][1].trans(stats['categs'][categdescr]['modules'][modname][branchname][1][1])
stats['categs'][categdescr]['modules'][modname][branchname].append((domname, stat))
stats['categs'][categdescr]['modules'][modname][branchname][0][1].trans(stat)
-
+
# Compute percentages and sorting
stats['total'] = stats['totaltrans'] + stats['totalfuzzy'] + stats['totaluntrans']
if stats['total'] > 0:
@@ -1249,19 +1249,19 @@ class FakeStatistics(object):
self.fuzzy = 0
self.untranslated = 0
self.partial_po = False
-
+
def trans(self, stat):
self.translated += stat.translated
self.fuzzy += stat.fuzzy
self.untranslated += stat.untranslated
stat.partial_po = True
-
+
def is_fake(self):
return True
def get_lang(self):
if self.language:
- return _("%(lang_name)s (%(lang_locale)s)") % {
+ return _("%(lang_name)s (%(lang_locale)s)") % {
'lang_name': _(self.language.name),
'lang_locale': self.language.locale
}
@@ -1329,7 +1329,7 @@ class Information(models.Model):
@classmethod
def get_info_dict(cls, lang):
- """ Return a dict (of lists) with all Information objects for a lang, with statistics_id as the key
+ """ Return a dict (of lists) with all Information objects for a lang, with statistics_id as the key
Used for caching and preventing db access when requesting these objects for a long list of stats """
info_dict = {}
for info in Information.objects.filter(statistics__language=lang):
@@ -1344,15 +1344,15 @@ class Information(models.Model):
def get_icon(self):
return "%simg/%s.png" % (settings.MEDIA_URL, self.type.split("-")[0])
-
+
def get_description(self):
text = self.description
- matches = re.findall('###([^#]*)###',text)
+ matches = re.findall('###([^#]*)###',text)
if matches:
text = re.sub('###([^#]*)###', '%s', text)
text = _(text)
-
+
#FIXME: if multiple substitutions, works only if order of %s is unchanged in translated string
for match in matches:
text = text.replace('%s',match,1)
@@ -1366,4 +1366,3 @@ class ArchivedInformation(models.Model):
class Meta:
db_table = 'archived_information'
-
diff --git a/stats/potdiff.py b/stats/potdiff.py
index b7fad94..c6842cc 100644
--- a/stats/potdiff.py
+++ b/stats/potdiff.py
@@ -76,7 +76,7 @@ def _parse_contents(contents):
if len(contents) and contents[-1] != "\n": contents += "\n"
# state machine for parsing PO files
- msgid = ""; msgstr = ""; msgctxt = ""; comment = ""; plural = "";
+ msgid = ""; msgstr = ""; msgctxt = ""; comment = ""; plural = "";
in_msgid = in_msgstr = in_msgctxt = in_msgid_plural = in_plural = 0
result = []
@@ -90,7 +90,7 @@ def _parse_contents(contents):
if line == "":
if in_msgstr and msgid != "":
onemsg = ""
-
+
if msgctxt: onemsg += ('"' + msgctxt + '"::')
onemsg += ('"' + msgid + '"')
if plural: onemsg += ('/"' + plural + '"')
@@ -148,4 +148,3 @@ def _parse_contents(contents):
if __name__ == "__main__":
import sys
print "\n".join(diff(sys.argv[1], sys.argv[2]))
-
diff --git a/stats/signals.py b/stats/signals.py
index d33d5b4..d59285f 100644
--- a/stats/signals.py
+++ b/stats/signals.py
@@ -1,4 +1,3 @@
import django.dispatch
pot_has_changed = django.dispatch.Signal(providing_args=["potfile", "branch", "domain"])
-
diff --git a/stats/templatetags/stats_extras.py b/stats/templatetags/stats_extras.py
index 64a03c9..7a9907f 100644
--- a/stats/templatetags/stats_extras.py
+++ b/stats/templatetags/stats_extras.py
@@ -4,7 +4,7 @@ register = template.Library()
@register.filter
def linked_with(value, arg):
- """ This filter returns an object (passed in value) enclosed with his absolute url
+ """ This filter returns an object (passed in value) enclosed with his absolute url
arg is the linked text """
return "<a href='%s'>%s</a>" % (value.get_absolute_url(), arg)
@@ -24,13 +24,13 @@ class IfLessNode(template.Node):
self.val2 = val2
self.nodelist_true = nodelist_true
self.nodelist_false = nodelist_false
-
+
def render(self, context):
if self.val1.resolve(context) < self.val2.resolve(context):
return self.nodelist_true.render(context)
else:
return self.nodelist_false.render(context)
-
+
@register.tag
def ifless(parser, token):
bits = list(token.split_contents())
diff --git a/stats/tests/__init__.py b/stats/tests/__init__.py
index f0b25ed..eb86af0 100644
--- a/stats/tests/__init__.py
+++ b/stats/tests/__init__.py
@@ -30,9 +30,9 @@ class ModuleTestCase(unittest.TestCase):
path = os.path.join(settings.SCRATCHDIR, 'git', 'gnome-hello')
if os.access(path, os.X_OK):
shutil.rmtree(path)
-
+
def setUp(self):
- # TODO: load bulk data from fixtures
+ # TODO: load bulk data from fixtures
Branch.checkout_on_creation = False
self.mod = Module(name="gnome-hello",
bugs_base="http://bugzilla.gnome.org",
@@ -49,23 +49,23 @@ class ModuleTestCase(unittest.TestCase):
self.b = Branch(name='master', module=self.mod)
self.b.save(update_statistics=False)
-
+
self.rel = Release(name='gnome-2-24', status='official',
description='GNOME 2.24 (stable)',
string_frozen=True)
self.rel.save()
-
+
self.cat = Category(release=self.rel, branch=self.b, name='desktop')
self.cat.save()
def testModuleFunctions(self):
self.assertEquals(self.mod.get_description(), 'gnome-hello')
-
+
def testBranchFunctions(self):
self.assertTrue(self.b.is_head())
self.assertEquals(self.b.get_vcs_url(), "git://git.gnome.org/gnome-hello")
self.assertEquals(self.b.get_vcs_web_url(), "http://git.gnome.org/cgit/gnome-hello/")
-
+
def testBranchStats(self):
# Check stats
self.b.update_stats(force=True)
@@ -73,7 +73,7 @@ class ModuleTestCase(unittest.TestCase):
self.assertEquals(fr_po_stat.translated, 40)
fr_doc_stat = Statistics.objects.get(branch=self.b, domain__name='help', language__locale='fr')
self.assertEquals(fr_doc_stat.translated, 36)
-
+
def testCreateAndDeleteBranch(self):
Branch.checkout_on_creation = True
# Create branch (include checkout)
@@ -91,7 +91,7 @@ class ModuleTestCase(unittest.TestCase):
mail.outbox = []
self.rel.string_frozen = True
self.rel.save()
-
+
# Create a new file with translation
new_file_path = os.path.join(self.b.co_path(), "dummy_file.py")
new_string = "Dummy string for D-L tests"
@@ -108,7 +108,7 @@ class ModuleTestCase(unittest.TestCase):
self.assertEquals(len(mail.outbox), 1);
self.assertEquals(mail.outbox[0].subject, "String additions to 'gnome-hello.master'")
self.assertTrue(mail.outbox[0].message().as_string().find(new_string)>-1)
-
+
def testIdenticalFigureWarning(self):
""" Detect warning if translated figure is identical to original figure """
self.b.checkout()
@@ -122,7 +122,7 @@ class ModuleTestCase(unittest.TestCase):
self.assertEquals(ui_stat.po_url(), u"/POT/gnome-hello.master/gnome-hello.master.fr.po");
self.assertEquals(ui_stat.pot_url(), u"/POT/gnome-hello.master/gnome-hello.master.pot");
self.assertEquals(doc_stat.po_url(), u"/POT/gnome-hello.master/docs/gnome-hello-help.master.fr.po");
-
+
def testCreateUnexistingBranch(self):
""" Try to create a non-existing branch """
Branch.checkout_on_creation = True
@@ -130,4 +130,3 @@ class ModuleTestCase(unittest.TestCase):
module = self.mod)
self.assertRaises(ValueError, branch.save)
Branch.checkout_on_creation = False
-
diff --git a/stats/utils.py b/stats/utils.py
index e592972..879b9c5 100644
--- a/stats/utils.py
+++ b/stats/utils.py
@@ -54,7 +54,7 @@ def stripHTML(string):
def run_shell_command(cmd, env=None, input_data=None, raise_on_error=False):
if settings.DEBUG: print >>sys.stderr, cmd
-
+
stdin = None
if input_data:
stdin = PIPE
@@ -69,7 +69,7 @@ def run_shell_command(cmd, env=None, input_data=None, raise_on_error=False):
if settings.DEBUG: print >>sys.stderr, output + errout
if raise_on_error and status != STATUS_OK:
raise OSError(status, errout)
-
+
return (status, output, errout)
@@ -105,7 +105,7 @@ def check_potfiles(po_path):
def generate_doc_pot_file(vcs_path, potbase, moduleid, verbose):
""" Return the pot file for a document-type domain, and the error if any """
-
+
errors = []
modulename = read_makefile_variable(vcs_path, "DOC_MODULE")
if not modulename:
@@ -117,17 +117,17 @@ def generate_doc_pot_file(vcs_path, potbase, moduleid, verbose):
else:
errors.append(("error", ugettext_noop("DOC_MODULE doesn't point to a real file, probably a macro.")))
return "", errors
-
+
files = os.path.join("C", modulename + ".xml")
includes = read_makefile_variable(vcs_path, "DOC_INCLUDES")
for f in includes.split(" "):
if f.strip() != "":
files += " %s" % (os.path.join("C", f.strip()))
-
+
potfile = os.path.join(vcs_path, "C", potbase + ".pot")
command = "cd \"%s\" && xml2po -o %s -e %s" % (vcs_path, potfile, files)
(status, output, errs) = run_shell_command(command)
-
+
if status != STATUS_OK:
errors.append(("error",
ugettext_noop("Error regenerating POT file for document %(file)s:\n<pre>%(cmd)s\n%(output)s</pre>")
@@ -179,7 +179,7 @@ def pot_diff_status(pota, potb):
# POT generation date always change and produce a 4 line diff
if int(output) <= 4:
return NOT_CHANGED, ""
-
+
result_all, result_add_only = potdiff.diff(pota, potb)
if not len(result_all) and not len(result_add_only):
return CHANGED_ONLY_FORMATTING, ""
@@ -213,7 +213,7 @@ def po_file_stats(pofile, msgfmt_checks = True):
input_file = "-"
else:
raise ValueError("pofile type not recognized")
-
+
if msgfmt_checks:
command = "msgfmt -cv -o /dev/null %s" % input_file
else:
@@ -229,7 +229,7 @@ def po_file_stats(pofile, msgfmt_checks = True):
if msgfmt_checks and input_file != "-" and os.access(pofile, os.X_OK):
res['errors'].append(("warn", ugettext_noop("This PO file has an executable bit set.")))
-
+
# msgfmt output stats on stderr
r_tr = re.search(r"([0-9]+) translated", errs)
r_un = re.search(r"([0-9]+) untranslated", errs)
@@ -237,9 +237,9 @@ def po_file_stats(pofile, msgfmt_checks = True):
if r_tr:
res['translated'] = r_tr.group(1)
- if r_un:
+ if r_un:
res['untranslated'] = r_un.group(1)
- if r_fz:
+ if r_fz:
res['fuzzy'] = r_fz.group(1)
if msgfmt_checks:
@@ -324,7 +324,7 @@ def check_lang_support(module_path, po_path, lang):
def get_fig_stats(pofile):
""" Extract image strings from pofile and return a list of figures dict {'path':, 'fuzzy':, 'translated':} """
- # Extract image strings: beforeline/msgid/msgstr/grep auto output a fourth line
+ # Extract image strings: beforeline/msgid/msgstr/grep auto output a fourth line
command = "msgcat --no-wrap %(pofile)s| grep -A 1 -B 1 '^msgid \"@@image:'" % locals()
(status, output, errs) = run_shell_command(command)
if status != STATUS_OK:
@@ -336,7 +336,7 @@ def get_fig_stats(pofile):
re_path = re.compile('^msgid \"@@image: \'([^\']*)\'')
re_hash = re.compile('.*md5=(.*)\"')
figures = []
-
+
for i, line in islice(enumerate(lines), 0, None, 4):
fig = {'path': '', 'hash': ''}
fig['fuzzy'] = (line=='#, fuzzy' or line[:8]=='#| msgid')
@@ -402,6 +402,6 @@ def url_join(base, *args):
class Profiler(object):
def __init__(self):
self.start = time.clock()
-
+
def time_spent(self):
- return time.clock() - self.start
+ return time.clock() - self.start
diff --git a/stats/views.py b/stats/views.py
index 1a965fe..c7e62db 100644
--- a/stats/views.py
+++ b/stats/views.py
@@ -50,7 +50,7 @@ def module(request, module_name):
for branch in branches:
branch.get_ui_stats(mandatory_langs=langs)
branch.get_doc_stats(mandatory_langs=langs)
-
+
context = {
'pageSection': "module",
'module': mod,
@@ -69,7 +69,7 @@ def module_branch(request, module_name, branch_name):
'branch': branch,
}
return render_to_response('branch_detail.html', context, context_instance=RequestContext(request))
-
+
@login_required
def module_edit_branches(request, module_name):
mod = get_object_or_404(Module, name=module_name)
@@ -131,7 +131,7 @@ def module_edit_branches(request, module_name):
form = ModuleBranchForm(mod) # Redisplay a clean form
else:
messages.append("Sorry, form is not valid")
- else:
+ else:
form = ModuleBranchForm(mod)
context = {
'module': mod,
@@ -143,7 +143,7 @@ def module_edit_branches(request, module_name):
def docimages(request, module_name, potbase, branch_name, langcode):
mod = get_object_or_404(Module, name=module_name)
stat = get_object_or_404(Statistics,
- branch__module=mod.id,
+ branch__module=mod.id,
branch__name=branch_name,
domain__name=potbase,
language__locale=langcode)
diff --git a/teams/forms.py b/teams/forms.py
index 6280a36..00124a5 100644
--- a/teams/forms.py
+++ b/teams/forms.py
@@ -14,7 +14,7 @@ class EditMemberRoleForm(forms.Form):
initial=role.role)
self.fields['form_type'] = forms.CharField(widget=forms.HiddenInput,
initial=roles[0].role)
-
+
def get_fields(self):
for key, field in self.fields.items():
if key not in ('form_type',):
diff --git a/teams/models.py b/teams/models.py
index b179462..5bf66b4 100644
--- a/teams/models.py
+++ b/teams/models.py
@@ -65,16 +65,16 @@ class Team(models.Model):
@models.permalink
def get_absolute_url(self):
return ('team_slug', [self.name])
-
+
def fill_role(self, role, person):
""" Used by TeamManager to prefill roles in team """
if not self.roles:
self.roles = {'coordinator':[], 'committer':[], 'reviewer':[], 'translator':[]}
self.roles[role].append(person)
-
+
def get_description(self):
return _(self.description)
-
+
def get_languages(self):
return self.language_set.all()
@@ -92,7 +92,7 @@ class Team(models.Model):
except:
members = Person.objects.filter(role__team__id=self.id, role__role=role)
return members
-
+
def get_committers(self):
return self.get_members_by_role('committer')
@@ -106,21 +106,21 @@ class FakeTeam(object):
""" This is a class replacing a Team object when a language
has no team attached """
fake = 1
-
+
def __init__(self, language):
self.language = language
self.description = _("No team for locale %s") % self.language.locale
-
+
def get_absolute_url(self):
- # FIXME: try to avoid using a hard-coded link
+ # FIXME: try to avoid using a hard-coded link
return "/teams/%s" % self.language.locale
-
+
def get_description(self):
return self.language.locale
def get_languages(self):
return (self.language,)
-
+
def get_coordinator(self):
return None
@@ -135,7 +135,7 @@ ROLE_CHOICES = (
class Role(models.Model):
""" This is the intermediary class between Person and Team to attribute
roles to Team members. """
-
+
team = models.ForeignKey(Team)
person = models.ForeignKey(Person)
role = models.CharField(max_length=15, choices=ROLE_CHOICES, default='translator')
@@ -143,7 +143,6 @@ class Role(models.Model):
class Meta:
db_table = 'role'
unique_together = ('team', 'person')
-
+
def __unicode__(self):
return "%s is %s in %s team" % (self.person.name, self.role, self.team.description)
-
diff --git a/teams/urls.py b/teams/urls.py
index 7a71f52..1e3b6c0 100644
--- a/teams/urls.py
+++ b/teams/urls.py
@@ -5,7 +5,7 @@ info_dict = {
'queryset': Team.objects.all(),
'template_object_name': 'team',
'slug_field': 'name',
- 'extra_context': {
+ 'extra_context': {
'pageSection': "teams"
}
}
diff --git a/teams/views.py b/teams/views.py
index 0a1a171..23ced02 100644
--- a/teams/views.py
+++ b/teams/views.py
@@ -31,8 +31,8 @@ def teams(request):
teams = Team.objects.all_with_roles()
context = {
- 'pageSection': 'teams',
- 'teams': utils.trans_sort_object_list(teams, 'description')
+ 'pageSection': 'teams',
+ 'teams': utils.trans_sort_object_list(teams, 'description')
}
return render_to_response('teams/team_list.html', context, context_instance=RequestContext(request))
@@ -40,7 +40,7 @@ def team(request, team_slug):
try:
team = Team.objects.get(name=team_slug)
coordinator = team.get_coordinator()
- mem_groups = (
+ mem_groups = (
{'title': _("Committers"),
'members': team.get_committers(),
'form': None,
@@ -95,4 +95,3 @@ def team(request, team_slug):
'mem_groups': mem_groups
}
return render_to_response('teams/team_detail.html', context, context_instance=RequestContext(request))
-
diff --git a/urls.py b/urls.py
index 053f198..90a75d1 100644
--- a/urls.py
+++ b/urls.py
@@ -38,7 +38,7 @@ urlpatterns += patterns('stats.views',
if 'django_openid' in settings.INSTALLED_APPS:
from django_openid.auth import AuthConsumer
-
+
urlpatterns += patterns('',
# ...
(r'^openid/(.*)', AuthConsumer()),
diff --git a/vertimus/feeds.py b/vertimus/feeds.py
index c849a65..5254384 100644
--- a/vertimus/feeds.py
+++ b/vertimus/feeds.py
@@ -32,7 +32,7 @@ from common.utils import imerge_sorted_by_field
class LatestActionsByLanguage(Feed):
title_template = 'feeds/actions_title.html'
description_template = 'feeds/actions_description.html'
-
+
def get_object(self, bits):
if len(bits) != 1:
raise ObjectDoesNotExist
@@ -61,8 +61,8 @@ class LatestActionsByLanguage(Feed):
return (action_db.get_action() for action_db in islice(imerge_sorted_by_field(actions_db, archived_actions_db, '-created'), 20))
def item_link(self, item):
- return urlresolvers.reverse('vertimus-names-view',
- args=(item.state.branch.module.name,
+ return urlresolvers.reverse('vertimus-names-view',
+ args=(item.state.branch.module.name,
item.state.branch.name,
item.state.domain.name,
item.state.language.locale))
@@ -108,8 +108,8 @@ class LatestActionsByTeam(Feed):
return (action_db.get_action() for action_db in islice(imerge_sorted_by_field(actions_db, archived_actions_db, '-created'), 20))
def item_link(self, item):
- return urlresolvers.reverse('vertimus-names-view',
- args=(item.state.branch.module.name,
+ return urlresolvers.reverse('vertimus-names-view',
+ args=(item.state.branch.module.name,
item.state.branch.name,
item.state.domain.name,
item.state.language.locale))
diff --git a/vertimus/forms.py b/vertimus/forms.py
index e4d91e8..ea877e5 100644
--- a/vertimus/forms.py
+++ b/vertimus/forms.py
@@ -27,7 +27,7 @@ from vertimus.models import ActionAbstract
from stats.utils import po_file_stats
class ActionWidget(forms.Select):
- """ Custom widget to disable the separator option (containing "--------") """
+ """ Custom widget to disable the separator option (containing "--------") """
def render_options(self, choices, selected_choices):
options = super(ActionWidget, self).render_options(choices, selected_choices)
options = options.replace("<option value=\"None\">--------</option>",
@@ -69,15 +69,14 @@ class ActionForm(forms.Form):
action = ActionAbstract.new_by_name(cleaned_data.get('action'))
comment = cleaned_data.get('comment')
file = cleaned_data.get('file')
-
+
if action.arg_is_required and not comment and not file:
raise forms.ValidationError(_("A comment or a file is needed for this action."))
if action.file_is_required and not file:
raise forms.ValidationError(_("A file is needed for this action."))
-
+
if action.file_is_prohibited and file:
raise forms.ValidationError(_("Please, don't send a file with a 'Reserve' action."))
return cleaned_data
-
diff --git a/vertimus/views.py b/vertimus/views.py
index e4ba70e..7ea4429 100644
--- a/vertimus/views.py
+++ b/vertimus/views.py
@@ -73,7 +73,7 @@ def vertimus(request, branch, domain, language, stats=None):
if request.user.is_authenticated():
# Only authenticated user can act on the translation
person = request.user.person
-
+
available_actions = [(va.name, va.description) for va in state.get_available_actions(person)]
if request.method == 'POST':
action_form = ActionForm(available_actions, request.POST, request.FILES)
@@ -82,13 +82,13 @@ def vertimus(request, branch, domain, language, stats=None):
# Process the data in form.cleaned_data
action = action_form.cleaned_data['action']
comment = action_form.cleaned_data['comment']
-
+
action = ActionAbstract.new_by_name(action)
new_state = state.apply_action(action, person, comment, request.FILES.get('file', None))
new_state.save()
return HttpResponseRedirect(
- urlresolvers.reverse('vertimus-names-view',
+ urlresolvers.reverse('vertimus-names-view',
args=(branch.module.name, branch.name, domain.name, language.locale)))
else:
action_form = ActionForm(available_actions)
@@ -105,7 +105,7 @@ def vertimus(request, branch, domain, language, stats=None):
'module': branch.module,
'non_standard_repo_msg' : _(settings.VCS_HOME_WARNING),
'state': state,
- 'action_history': action_history,
+ 'action_history': action_history,
'action_form': action_form
}
return render_to_response('vertimus/vertimus_detail.html', context,
@@ -125,7 +125,7 @@ def vertimus_diff(request, action_id_1, action_id_2=None):
try:
content_1 = [l.decode('utf-8') for l in open(file_path_1, 'U').readlines()]
except UnicodeDecodeError:
- return render_to_response('error.html',
+ return render_to_response('error.html',
{'error': _("Error: The file %s contains invalid characters.") % file_path_1.split('/')[-1]})
descr_1 = _("Uploaded file by %(name)s on %(date)s") % { 'name': action_1.person.name,
'date': action_1.created }
@@ -135,7 +135,7 @@ def vertimus_diff(request, action_id_1, action_id_2=None):
file_path_2 = action_2.merged_file()['path']
descr_2 = _("Uploaded file by %(name)s on %(date)s") % { 'name': action_2.person.name,
'date': action_2.created }
- else:
+ else:
action_2 = None
if action_id_2 is None:
# 2) Search previous in action history
@@ -157,7 +157,7 @@ def vertimus_diff(request, action_id_1, action_id_2=None):
try:
content_2 = [l.decode('utf-8') for l in open(file_path_2, 'U').readlines()]
except UnicodeDecodeError:
- return render_to_response('error.html',
+ return render_to_response('error.html',
{'error': _("Error: The file %s contains invalid characters.") % file_path_2.split('/')[-1]})
d = difflib.HtmlDiff(wrapcolumn=80)
diff_content = d.make_table(content_2, content_1,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]