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

PEP-8 for not in conditions

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent e41ed56e
......@@ -111,7 +111,7 @@ def user_full_name(strategy, details, user=None, **kwargs):
first_name = details.get('first_name', '')
last_name = details.get('last_name', '')
if first_name and not first_name in last_name:
if first_name and first_name not in last_name:
full_name = u'{0} {1}'.format(first_name, last_name)
elif first_name:
full_name = first_name
......
......@@ -387,7 +387,7 @@ class Language(models.Model, PercentMixin):
self._percents = None
def __unicode__(self):
if (not '(' in self.name
if ('(' not in self.name
and ('_' in self.code or '-' in self.code)
and self.code not in ('zh_TW', 'zh_CN')):
return '%s (%s)' % (_(self.name), self.code)
......
......@@ -111,7 +111,7 @@ class BaseFormatCheck(TargetCheck):
Checks single unit, handling plurals.
'''
# Verify unit is properly flagged
if not self.flag in unit.all_flags:
if self.flag not in unit.all_flags:
return False
# Special case languages with single plural form
......
......@@ -94,7 +94,7 @@ class XMLTagsCheck(TargetCheck):
# Do we need to process source (cache miss)
if source_tags is None:
# Quick check if source looks like XML
if not '<' in source or len(XML_MATCH.findall(source)) == 0:
if '<' not in source or len(XML_MATCH.findall(source)) == 0:
self.set_cache(unit, [], cache_slot)
return False
# Check if source is XML
......
......@@ -386,7 +386,7 @@ class FileFormat(object):
'''
return (
(self.monolingual or self.monolingual is None)
and not self.template_store is None
and self.template_store is not None
)
def find_unit(self, context, source):
......@@ -452,7 +452,7 @@ class FileFormat(object):
# Adjust Content-Type header if needed
header = self.store.parseheader()
if (not 'Content-Type' in header
if ('Content-Type' not in header
or 'charset=CHARSET' in header['Content-Type']
or 'charset=ASCII' in header['Content-Type']):
kwargs['Content_Type'] = 'text/plain; charset=UTF-8'
......
......@@ -115,7 +115,7 @@ class PluralTextarea(forms.Textarea):
ret = [data.get(name, None)]
for idx in range(1, 10):
fieldname = '%s_%d' % (name, idx)
if not fieldname in data:
if fieldname not in data:
break
ret.append(data.get(fieldname, None))
ret = [smart_unicode(r.replace('\r', '')) for r in ret]
......
......@@ -55,7 +55,7 @@ class GlosbeTranslation(MachineTranslation):
**params
)
if not 'tuc' in response:
if 'tuc' not in response:
return []
return [(match['phrase']['text'], 100, self.name, text)
......
......@@ -149,7 +149,7 @@ class Command(BaseCommand):
)
# Do we have correct mask?
if not '**' in filemask:
if '**' not in filemask:
raise CommandError(
'You need to specify double wildcard '
'for subproject part of the match!'
......
......@@ -526,7 +526,7 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
return self.linked_subproject.configure_branch()
# create branch if it does not exist
if not self.branch in self.git_repo.heads:
if self.branch not in self.git_repo.heads:
self.git_repo.git.branch(
'--track',
self.branch,
......
......@@ -107,7 +107,7 @@ class UnitManager(models.Manager):
checks = checks.filter(language=translation.language)
# Filter by check type
if not rqtype in ['allchecks', 'sourcechecks']:
if rqtype not in ('allchecks', 'sourcechecks'):
checks = checks.filter(check=rqtype)
checks = checks.values_list('contentsum', flat=True)
......@@ -644,7 +644,7 @@ class Unit(models.Model):
git backend (eg. commit or by parsing file).
'''
# Warn if request is not coming from backend
if not 'backend' in kwargs:
if 'backend' not in kwargs:
weblate.logger.error(
'Unit.save called without backend sync: %s',
''.join(traceback.format_stack())
......
......@@ -75,7 +75,7 @@ def validate_filemask(val):
'''
Validates file mask that it contains *.
'''
if not '*' in val:
if '*' not in val:
raise ValidationError(
_('File mask does not contain * as a language placeholder!')
)
......
......@@ -241,7 +241,7 @@ def download_dictionary(request, project, lang):
export_format = None
if 'format' in request.GET:
export_format = request.GET['format']
if not export_format in ['csv', 'po', 'tbx']:
if export_format not in ('csv', 'po', 'tbx'):
export_format = 'csv'
# Grab all words
......
......@@ -58,7 +58,7 @@ def translate(request, unit_id):
service_name = request.GET.get('service', 'INVALID')
if not service_name in MACHINE_TRANSLATION_SERVICES:
if service_name not in MACHINE_TRANSLATION_SERVICES:
return HttpResponseBadRequest('Invalid service specified')
translation_service = MACHINE_TRANSLATION_SERVICES[service_name]
......
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