Commit b50a07d1 authored by Michal Čihař's avatar Michal Čihař

Various coding style improvements

parent e308d21e
...@@ -142,7 +142,8 @@ SAME_BLACKLIST = frozenset(( ...@@ -142,7 +142,8 @@ SAME_BLACKLIST = frozenset((
'www', 'www',
'xml', 'xml',
'zip', 'zip',
)) )
)
DEFAULT_CHECK_LIST = ( DEFAULT_CHECK_LIST = (
'weblate.trans.checks.SameCheck', 'weblate.trans.checks.SameCheck',
...@@ -215,9 +216,12 @@ class Check(object): ...@@ -215,9 +216,12 @@ class Check(object):
''' '''
if len(target) == 0 or len(source) == 0: if len(target) == 0 or len(source) == 0:
return False return False
s = source[pos] src = source[pos]
t = target[pos] tgt = target[pos]
return (s in chars and t not in chars) or (s not in chars and t in chars) return (
(src in chars and tgt not in chars)
or (src not in chars and tgt in chars)
)
def check_format_strings(self, source, target, regex, unit): def check_format_strings(self, source, target, regex, unit):
''' '''
...@@ -255,7 +259,10 @@ class Check(object): ...@@ -255,7 +259,10 @@ class Check(object):
''' '''
Returns link to documentation. Returns link to documentation.
''' '''
return weblate.get_doc_url('usage', 'check-%s' % self.check_id.replace('_', '-')) return weblate.get_doc_url(
'usage',
'check-%s' % self.check_id.replace('_', '-')
)
def get_cache_key(self, unit): def get_cache_key(self, unit):
''' '''
...@@ -283,13 +290,11 @@ class TargetCheck(Check): ...@@ -283,13 +290,11 @@ class TargetCheck(Check):
target = True target = True
class SourceCheck(Check): class SourceCheck(Check):
''' '''
Basic class for source checks. Basic class for source checks.
''' '''
source= True source = True
class SameCheck(TargetCheck): class SameCheck(TargetCheck):
...@@ -309,7 +314,6 @@ class SameCheck(TargetCheck): ...@@ -309,7 +314,6 @@ class SameCheck(TargetCheck):
stripped = regex.sub('', msg) stripped = regex.sub('', msg)
return stripped.strip(' ,./<>?;\'\\:"|[]{}`~!@#$%^&*()-=_+') == '' return stripped.strip(' ,./<>?;\'\\:"|[]{}`~!@#$%^&*()-=_+') == ''
def check_single(self, source, target, flags, language, unit): def check_single(self, source, target, flags, language, unit):
# Ignore strings which don't contain any string to translate # Ignore strings which don't contain any string to translate
if 'python-format' in flags and self.is_format_only(source, PYTHON_PRINTF_MATCH): if 'python-format' in flags and self.is_format_only(source, PYTHON_PRINTF_MATCH):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment