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

Some pep8 cleanups

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 8fe9908b
......@@ -77,8 +77,8 @@ def openshift_secure(default_keys, secure_function='make_secure_key'):
base = os.getenv('OPENSHIFT_REPO_DIR')
calling_file.replace(base, '')
sys.stderr.write(
"OPENSHIFT WARNING: Using default values for secure variables, "
+ "please manually modify in " + calling_file + "\n"
"OPENSHIFT WARNING: Using default values for secure variables, " +
"please manually modify in " + calling_file + "\n"
)
return my_list
......
......@@ -82,6 +82,6 @@ def disable_anon_user_password_save(sender, **kwargs):
Blocks setting password for anonymous user.
'''
instance = kwargs['instance']
if (instance.username == ANONYMOUS_USER_NAME
and instance.has_usable_password()):
if (instance.username == ANONYMOUS_USER_NAME and
instance.has_usable_password()):
raise ValueError('Anonymous user can not have usable password!')
......@@ -101,8 +101,8 @@ class MathCaptcha(object):
Validates answer.
'''
return (
self.result == answer
and self.timestamp + TIMEDELTA > time.time()
self.result == answer and
self.timestamp + TIMEDELTA > time.time()
)
@property
......
......@@ -371,8 +371,8 @@ class CaptchaRegistrationForm(RegistrationForm):
'''
Validation for captcha.
'''
if (self.tampering
or not self.captcha.validate(self.cleaned_data['captcha'])):
if (self.tampering or
not self.captcha.validate(self.cleaned_data['captcha'])):
raise forms.ValidationError(
_('Please check your math and try again.')
)
......
......@@ -592,16 +592,16 @@ def post_login_handler(sender, request, user, **kwargs):
'''
# Warning about setting password
if (getattr(user, 'backend', '') == 'social.backends.email.EmailAuth'
and not user.has_usable_password()):
if (getattr(user, 'backend', '') == 'social.backends.email.EmailAuth' and
not user.has_usable_password()):
request.session['show_set_password'] = True
# Ensure user has a profile
profile = Profile.objects.get_or_create(user=user)[0]
# Migrate django-registration based verification to python-social-auth
if (user.has_usable_password()
and not user.social_auth.filter(provider='email').exists()):
if (user.has_usable_password() and
not user.social_auth.filter(provider='email').exists()):
social = user.social_auth.create(
provider='email',
uid=user.email,
......
......@@ -380,8 +380,8 @@ LOGGING = {
}
# Logging of management commands to console
if (os.environ.get('DJANGO_IS_MANAGEMENT_COMMAND', False)
and 'console' not in LOGGING['loggers']['weblate']['handlers']):
if (os.environ.get('DJANGO_IS_MANAGEMENT_COMMAND', False) and
'console' not in LOGGING['loggers']['weblate']['handlers']):
LOGGING['loggers']['weblate']['handlers'].append('console')
# Remove syslog setup if it's not present
......
......@@ -18,9 +18,9 @@ from weblate.trans.tests.test_views import RegistrationTestMixin
# Check whether we should run Selenium tests
DO_SELENIUM = (
('DO_SELENIUM' in os.environ or 'CI_SELENIUM' in os.environ)
and 'SAUCE_USERNAME' in os.environ
and 'SAUCE_ACCESS_KEY' in os.environ
('DO_SELENIUM' in os.environ or 'CI_SELENIUM' in os.environ) and
'SAUCE_USERNAME' in os.environ and
'SAUCE_ACCESS_KEY' in os.environ
)
......
......@@ -296,8 +296,8 @@ def handle_translate(translation, request, user_locked,
request,
_('You don\'t have privileges to save translations!')
)
elif (unit.only_vote_suggestions()
and not request.user.has_perm('trans.override_suggestion')):
elif (unit.only_vote_suggestions() and not
request.user.has_perm('trans.override_suggestion')):
messages.error(
request,
_('Only suggestions are allowed in this translation!')
......@@ -510,10 +510,10 @@ def translate(request, project, subproject, lang):
if request.method == 'POST' and not project_locked:
# Handle accepting/deleting suggestions
if ('accept' not in request.POST
and 'delete' not in request.POST
and 'upvote' not in request.POST
and 'downvote' not in request.POST):
if ('accept' not in request.POST and
'delete' not in request.POST and
'upvote' not in request.POST and
'downvote' not in request.POST):
response = handle_translate(
translation, request, user_locked,
this_unit_url, next_unit_url
......
......@@ -93,9 +93,9 @@ def upload_translation(request, project, subproject, lang):
# Create author name
author = None
if (request.user.has_perm('trans.author_translation')
and form.cleaned_data['author_name'] != ''
and form.cleaned_data['author_email'] != ''):
if (request.user.has_perm('trans.author_translation') and
form.cleaned_data['author_name'] != '' and
form.cleaned_data['author_email'] != ''):
author = '%s <%s>' % (
form.cleaned_data['author_name'],
form.cleaned_data['author_email']
......
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