a
, img
, strong
,
b
, em
, li
, u
, p
, br
,
@@ -80,7 +80,7 @@ class BwNewThreadForm(NewThreadForm):
def __init__(self, *args, **kwargs):
kwargs.update(dict(label_suffix=''))
- super(BwNewThreadForm, self).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
html_tags_help_text = """Allowed HTML tags: a
, img
, strong
,
b
, em
, li
, u
, p
, br
,
diff --git a/forum/migrations/0001_initial.py b/forum/migrations/0001_initial.py
index 737a112a0f..49a2658cda 100644
--- a/forum/migrations/0001_initial.py
+++ b/forum/migrations/0001_initial.py
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
# Generated by Django 1.9.5 on 2016-04-15 11:33
-from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
@@ -89,6 +87,6 @@ class Migration(migrations.Migration):
),
migrations.AlterUniqueTogether(
name='subscription',
- unique_together=set([('subscriber', 'thread')]),
+ unique_together={('subscriber', 'thread')},
),
]
diff --git a/forum/migrations/0002_auto_20171127_1627.py b/forum/migrations/0002_auto_20171127_1627.py
index 4ad2a465bb..8166b74da9 100644
--- a/forum/migrations/0002_auto_20171127_1627.py
+++ b/forum/migrations/0002_auto_20171127_1627.py
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-11-27 16:27
-from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
diff --git a/forum/migrations/0003_auto_20230201_1102.py b/forum/migrations/0003_auto_20230201_1102.py
index 383327758d..984eb38daf 100644
--- a/forum/migrations/0003_auto_20230201_1102.py
+++ b/forum/migrations/0003_auto_20230201_1102.py
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2023-02-01 11:02
-from __future__ import unicode_literals
from django.db import migrations, models
diff --git a/forum/models.py b/forum/models.py
index 655b32ef62..c53ea47a66 100644
--- a/forum/models.py
+++ b/forum/models.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
#
# Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA
#
@@ -22,7 +20,6 @@
from future import standard_library
standard_library.install_aliases()
-from builtins import object
import logging
from collections import Counter
@@ -149,7 +146,7 @@ def get_most_relevant_commenters_info_for_avatars(self):
}
return info_to_return
- class Meta(object):
+ class Meta:
ordering = ('-status', '-last_post__created')
def __str__(self):
@@ -222,14 +219,14 @@ class Post(models.Model):
)
moderation_state = models.CharField(db_index=True, max_length=2, choices=MODERATION_STATE_CHOICES, default="OK")
- class Meta(object):
+ class Meta:
ordering = ('created',)
permissions = (
("can_moderate_forum", "Can moderate posts."),
)
def __str__(self):
- return u"Post by %s in %s" % (self.author, self.thread)
+ return "Post by %s in %s" % (self.author, self.thread)
def get_absolute_url(self):
return reverse("forums-post", args=[smart_text(self.thread.forum.name_slug), self.thread.id, self.id])
@@ -348,8 +345,8 @@ class Subscription(models.Model):
thread = models.ForeignKey(Thread)
is_active = models.BooleanField(db_index=True, default=True)
- class Meta(object):
+ class Meta:
unique_together = ("subscriber", "thread")
def __str__(self):
- return u"%s subscribed to %s" % (self.subscriber, self.thread)
+ return "%s subscribed to %s" % (self.subscriber, self.thread)
diff --git a/forum/templatetags/display_forum_objects.py b/forum/templatetags/display_forum_objects.py
index 0f47a48b3f..4809cf48b2 100644
--- a/forum/templatetags/display_forum_objects.py
+++ b/forum/templatetags/display_forum_objects.py
@@ -18,9 +18,7 @@
# See AUTHORS file.
#
-from __future__ import absolute_import
-from builtins import str
from django import template
register = template.Library()
diff --git a/forum/templatetags/display_forum_search_results.py b/forum/templatetags/display_forum_search_results.py
index 405d4e0ae3..eba7a1bfd4 100644
--- a/forum/templatetags/display_forum_search_results.py
+++ b/forum/templatetags/display_forum_search_results.py
@@ -3,8 +3,6 @@
@author: stelios
'''
-from __future__ import absolute_import
-from builtins import str
from django import template
register = template.Library()
diff --git a/forum/templatetags/smileys.py b/forum/templatetags/smileys.py
index 97003aa8cd..227a7be65a 100644
--- a/forum/templatetags/smileys.py
+++ b/forum/templatetags/smileys.py
@@ -30,7 +30,7 @@ def smiley_replace(matchobj):
except KeyError:
return matchobj.group(0)
-smiley_replacer = re.compile("=\)|;\-?\)|8\-?\)|:'\(|:\-?[OoPpSsDd\)\(\|]")
+smiley_replacer = re.compile(r"=\)|;\-?\)|8\-?\)|:'\(|:\-?[OoPpSsDd\)\(\|]")
@register.filter(is_safe=True)
def smileys(string):
diff --git a/forum/tests.py b/forum/tests.py
index d129691593..6a27c76fcf 100644
--- a/forum/tests.py
+++ b/forum/tests.py
@@ -19,8 +19,6 @@
#
from future import standard_library
standard_library.install_aliases()
-from builtins import str
-from builtins import range
from django.conf import settings
from django.contrib.auth.models import User, Group
from django.core import mail
@@ -343,7 +341,7 @@ def test_new_thread_response_ok(self):
# Assert non-logged in user is redirected to login page
resp = self.client.post(reverse('forums-new-thread', args=[forum.name_slug]), data={
- u'body': [u'New thread body (first post)'], u'subscribe': [u'on'], u'title': [u'New thread title']
+ 'body': ['New thread body (first post)'], 'subscribe': ['on'], 'title': ['New thread title']
})
self.assertRedirects(resp, '%s?next=%s' % (
reverse('login'), reverse('forums-new-thread', args=[forum.name_slug])))
@@ -351,9 +349,9 @@ def test_new_thread_response_ok(self):
# Assert logged in user can create new thread
self.client.force_login(self.user)
resp = self.client.post(reverse('forums-new-thread', args=[forum.name_slug]), data={
- u'body': [u'New thread body (first post)'], u'subscribe': [u'on'], u'title': [u'New thread title']
+ 'body': ['New thread body (first post)'], 'subscribe': ['on'], 'title': ['New thread title']
})
- post = Post.objects.get(body=u'New thread body (first post)')
+ post = Post.objects.get(body='New thread body (first post)')
self.assertRedirects(resp, post.get_absolute_url(), target_status_code=302)
@override_settings(LAST_FORUM_POST_MINIMUM_TIME=0)
@@ -364,7 +362,7 @@ def test_new_thread_title_length(self):
long_title = 255 * '1'
self.client.force_login(self.user)
resp = self.client.post(reverse('forums-new-thread', args=[forum.name_slug]), data={
- u'body': [u'New thread body (first post)'], u'subscribe': [u'on'], u'title': [long_title]
+ 'body': ['New thread body (first post)'], 'subscribe': ['on'], 'title': [long_title]
})
self.assertNotEqual(resp.context['form'].errors, None)
@@ -390,7 +388,7 @@ def test_thread_reply_response_ok(self):
# Assert non-logged in user is redirected to login page
resp = self.client.post(reverse('forums-reply', args=[forum.name_slug, thread.id]), data={
- u'body': [u'Reply post body'], u'subscribe': [u'on'],
+ 'body': ['Reply post body'], 'subscribe': ['on'],
})
self.assertRedirects(resp, '%s?next=%s' % (
reverse('login'), reverse('forums-reply', args=[forum.name_slug, thread.id])))
@@ -398,9 +396,9 @@ def test_thread_reply_response_ok(self):
# Assert logged in user can reply
self.client.force_login(self.user)
resp = self.client.post(reverse('forums-reply', args=[forum.name_slug, thread.id]), data={
- u'body': [u'Reply post body'], u'subscribe': [u'on'],
+ 'body': ['Reply post body'], 'subscribe': ['on'],
})
- post = Post.objects.get(body=u'Reply post body')
+ post = Post.objects.get(body='Reply post body')
self.assertRedirects(resp, post.get_absolute_url(), target_status_code=302)
@override_settings(LAST_FORUM_POST_MINIMUM_TIME=0)
@@ -411,7 +409,7 @@ def test_thread_reply_quote_post_response_ok(self):
# Assert non-logged in user is redirected to login page
resp = self.client.post(reverse('forums-reply-quote', args=[forum.name_slug, thread.id, post.id]), data={
- u'body': [u'Reply post body'], u'subscribe': [u'on'],
+ 'body': ['Reply post body'], 'subscribe': ['on'],
})
self.assertRedirects(resp, '%s?next=%s' % (
reverse('login'), reverse('forums-reply-quote', args=[forum.name_slug, thread.id, post.id])))
@@ -419,9 +417,9 @@ def test_thread_reply_quote_post_response_ok(self):
# Assert logged in user can reply
self.client.force_login(self.user)
resp = self.client.post(reverse('forums-reply-quote', args=[forum.name_slug, thread.id, post.id]), data={
- u'body': [u'Reply post body'], u'subscribe': [u'on'],
+ 'body': ['Reply post body'], 'subscribe': ['on'],
})
- post = Post.objects.get(body=u'Reply post body')
+ post = Post.objects.get(body='Reply post body')
self.assertRedirects(resp, post.get_absolute_url(), target_status_code=302)
def test_edit_post_response_ok(self):
@@ -431,7 +429,7 @@ def test_edit_post_response_ok(self):
# Assert non-logged in user can't edit post
resp = self.client.post(reverse('forums-post-edit', args=[post.id]), data={
- u'body': [u'Edited post body']
+ 'body': ['Edited post body']
})
self.assertRedirects(resp, '%s?next=%s' % (reverse('login'), reverse('forums-post-edit', args=[post.id])))
@@ -439,18 +437,18 @@ def test_edit_post_response_ok(self):
user2 = User.objects.create_user(username='testuser2', email='email2@example.com', password='12345')
self.client.force_login(user2)
resp = self.client.post(reverse('forums-post-edit', args=[post.id]), data={
- u'body': [u'Edited post body']
+ 'body': ['Edited post body']
})
self.assertEqual(resp.status_code, 404)
# Assert logged in user can edit post
self.client.force_login(self.user)
resp = self.client.post(reverse('forums-post-edit', args=[post.id]), data={
- u'body': [u'Edited post body']
+ 'body': ['Edited post body']
})
self.assertRedirects(resp, post.get_absolute_url(), target_status_code=302)
edited_post = Post.objects.get(id=post.id)
- self.assertEqual(edited_post.body, u'Edited post body')
+ self.assertEqual(edited_post.body, 'Edited post body')
def test_delete_post_response_ok(self):
forum = Forum.objects.first()
@@ -572,9 +570,9 @@ def test_emails_sent_for_subscription_to_thread(self):
self.assertEqual(Subscription.objects.filter(thread=thread, subscriber=user2).count(), 1)
resp = self.client.post(reverse('forums-reply-quote', args=[forum.name_slug, thread.id, post.id]), data={
- u'body': [u'Reply post body'], u'subscribe': [u'on'],
+ 'body': ['Reply post body'], 'subscribe': ['on'],
})
- post = Post.objects.get(body=u'Reply post body')
+ post = Post.objects.get(body='Reply post body')
self.assertRedirects(resp, post.get_absolute_url(), target_status_code=302)
# Both users are subscribed but the email is not sent to the user that is sending the post
@@ -601,7 +599,7 @@ def test_emails_not_sent_for_subscription_to_thread_if_preference_disabled(self)
user2 = User.objects.create_user(username='testuser2', email='email2@example.com', password='12345')
self.client.force_login(user2)
self.client.post(reverse('forums-reply-quote', args=[forum.name_slug, thread.id, post.id]), data={
- u'body': [u'Reply post body'], u'subscribe': [u'on'],
+ 'body': ['Reply post body'], 'subscribe': ['on'],
})
# No emails sent
@@ -627,7 +625,7 @@ def test_user_no_permissions(self):
"""If the user doesn't have forum.can_moderate_forum permission, they're redirected to login screen"""
self.client.force_login(self.regular_user)
resp = self.client.post(reverse('forums-moderate'), data={
- u'action': [u'Delete'], u'post': [u'1'],
+ 'action': ['Delete'], 'post': ['1'],
})
self.assertEqual(resp.status_code, 302)
@@ -636,7 +634,7 @@ def test_approve_post(self):
self.client.force_login(self.admin_user)
resp = self.client.post(reverse('forums-moderate'), data={
- u'action': [u'Approve'], u'post': [str(self.post.id)],
+ 'action': ['Approve'], 'post': [str(self.post.id)],
})
self.assertEqual(resp.status_code, 200)
self.post.refresh_from_db()
@@ -647,7 +645,7 @@ def test_delete_user(self):
self.client.force_login(self.admin_user)
resp = self.client.post(reverse('forums-moderate'), data={
- u'action': [u'Delete User'], u'post': [str(self.post.id)],
+ 'action': ['Delete User'], 'post': [str(self.post.id)],
})
self.assertEqual(resp.status_code, 200)
with self.assertRaises(Post.DoesNotExist):
@@ -662,7 +660,7 @@ def test_delete_post(self):
self.client.force_login(self.admin_user)
resp = self.client.post(reverse('forums-moderate'), data={
- u'action': [u'Delete Post'], u'post': [str(self.post.id)],
+ 'action': ['Delete Post'], 'post': [str(self.post.id)],
})
self.assertEqual(resp.status_code, 200)
with self.assertRaises(Post.DoesNotExist):
@@ -677,7 +675,7 @@ def test_no_such_post(self):
self.client.force_login(self.admin_user)
resp = self.client.post(reverse('forums-moderate'), data={
- u'action': [u'Delete Post'], u'post': [str(self.post.id+1)],
+ 'action': ['Delete Post'], 'post': [str(self.post.id+1)],
})
self.assertEqual(resp.status_code, 200)
diff --git a/forum/urls.py b/forum/urls.py
index 6492d0cbda..9027f07a8a 100644
--- a/forum/urls.py
+++ b/forum/urls.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
#
# Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA
#
diff --git a/forum/views.py b/forum/views.py
index f9f93da693..992ca77fc7 100644
--- a/forum/views.py
+++ b/forum/views.py
@@ -18,7 +18,6 @@
# See AUTHORS file.
#
-from __future__ import division
from future import standard_library
standard_library.install_aliases()
@@ -262,7 +261,7 @@ def reply(request, forum_name_slug, thread_id, post_id=None):
subscription.is_active = False
subscription.save()
- if users_to_notify and post.thread.get_status_display() != u'Sunk':
+ if users_to_notify and post.thread.get_status_display() != 'Sunk':
send_mail_template(
settings.EMAIL_SUBJECT_TOPIC_REPLY,
"forum/email_new_post_notification.txt",
@@ -380,7 +379,7 @@ def subscribe_to_thread(request, forum_name_slug, thread_id):
def old_topic_link_redirect(request):
post_id = request.GET.get("p", False)
if post_id:
- post_id = re.sub("\D", "", post_id)
+ post_id = re.sub(r"\D", "", post_id)
try:
post = get_object_or_404(Post, id=post_id)
except ValueError:
@@ -390,7 +389,7 @@ def old_topic_link_redirect(request):
thread_id = request.GET.get("t", False)
if thread_id:
- thread_id = re.sub("\D", "", thread_id)
+ thread_id = re.sub(r"\D", "", thread_id)
try:
thread = get_object_or_404(Thread, id=thread_id)
except ValueError:
diff --git a/freesound/__init__.py b/freesound/__init__.py
index ff99efb2cd..1a6c551dd5 100644
--- a/freesound/__init__.py
+++ b/freesound/__init__.py
@@ -1,5 +1,3 @@
-from __future__ import absolute_import
-
# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from .celery import app as celery_app
diff --git a/freesound/celery.py b/freesound/celery.py
index d494155c0f..6e97c49437 100644
--- a/freesound/celery.py
+++ b/freesound/celery.py
@@ -1,4 +1,3 @@
-from __future__ import absolute_import
import os
import requests
from django.conf import settings
diff --git a/freesound/local_settings.example.py b/freesound/local_settings.example.py
index 220153986b..72f4e41683 100644
--- a/freesound/local_settings.example.py
+++ b/freesound/local_settings.example.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
import os
DEBUG = True
diff --git a/freesound/middleware.py b/freesound/middleware.py
index cb8b462f77..3d9e753406 100644
--- a/freesound/middleware.py
+++ b/freesound/middleware.py
@@ -18,7 +18,6 @@
# See AUTHORS file.
#
-from builtins import object
import json
import logging
@@ -46,7 +45,7 @@ def dont_redirect(path):
and not path.startswith(settings.MEDIA_URL)
-class OnlineUsersHandler(object):
+class OnlineUsersHandler:
def __init__(self, get_response):
self.get_response = get_response
@@ -56,7 +55,7 @@ def __call__(self, request):
return response
-class BulkChangeLicenseHandler(object):
+class BulkChangeLicenseHandler:
def __init__(self, get_response):
self.get_response = get_response
@@ -77,7 +76,7 @@ def __call__(self, request):
return response
-class FrontendPreferenceHandler(object):
+class FrontendPreferenceHandler:
def __init__(self, get_response):
self.get_response = get_response
@@ -97,7 +96,7 @@ def __call__(self, request):
return response
-class TosAcceptanceHandler(object):
+class TosAcceptanceHandler:
"""Checks if the user has accepted the updates to the Terms
of Service in 2022. This replaces the agreement to the original ToS (2013, 2fd543f3a).
When users agree with the new terms of service, they also agree on updating the
@@ -120,7 +119,7 @@ def __call__(self, request):
return response
-class UpdateEmailHandler(object):
+class UpdateEmailHandler:
message = "We have identified that some emails that we have sent to you didn't go through, thus it appears that " \
"your email address is not valid. Please update your email address to a working one to continue using " \
"Freesound"
diff --git a/freesound/settings.py b/freesound/settings.py
index 47a5bcae4e..eb1ba88164 100644
--- a/freesound/settings.py
+++ b/freesound/settings.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
import datetime
import os
import re
@@ -113,13 +111,13 @@
'oauth2_provider.RefreshToken',
'oauth2_provider.Grant',
)},
- str('forum'), # str() should be replaced when moving to Py3
+ 'forum',
{'app': 'donations', 'models': (
'donations.Donation',
'donations.DonationsEmailSettings',
'donations.DonationsModalSettings',
)},
- str('sites'), # str() should be replaced when moving to Py3
+ 'sites',
)
# Silk is the Request/SQL logging platform. We install it but leave it disabled
@@ -273,23 +271,23 @@
ALLOWED_EMAILS = []
# Email subjects
-EMAIL_SUBJECT_PREFIX = u'[freesound]'
-EMAIL_SUBJECT_ACTIVATION_LINK = u'Your activation link'
-EMAIL_SUBJECT_USERNAME_REMINDER = u'Username reminder'
-EMAIL_SUBJECT_EMAIL_CHANGED = u'Email address changed'
-EMAIL_SUBJECT_USER_SPAM_REPORT = u'Spam/offensive report for user'
-EMAIL_SUBJECT_DONATION_THANK_YOU = u'Thanks for your donation!'
-EMAIL_SUBJECT_DONATION_REMINDER = u'Thanks for contributing to Freesound'
-EMAIL_SUBJECT_DONATION_REQUEST = u'Have you considered making a donation?'
-EMAIL_SUBJECT_STREAM_EMAILS = u'New sounds from users and tags you are following'
-EMAIL_SUBJECT_TOPIC_REPLY = u'Topic reply notification'
-EMAIL_SUBJECT_PRIVATE_MESSAGE = u'You have a private message'
-EMAIL_SUBJECT_SOUND_ADDED_AS_REMIX = u'Sound added as remix source'
-EMAIL_SUBJECT_RANDOM_SOUND_OF_THE_SAY_CHOOSEN = u'One of your sounds has been chosen as random sound of the day!'
-EMAIL_SUBJECT_NEW_COMMENT = u'You have a new comment'
-EMAIL_SUBJECT_SOUND_FLAG = u'Sound flag'
-EMAIL_SUBJECT_SUPPORT_EMAIL = u'[support]'
-EMAIL_SUBJECT_MODERATION_HANDLED = u'A Freesound moderator handled your upload'
+EMAIL_SUBJECT_PREFIX = '[freesound]'
+EMAIL_SUBJECT_ACTIVATION_LINK = 'Your activation link'
+EMAIL_SUBJECT_USERNAME_REMINDER = 'Username reminder'
+EMAIL_SUBJECT_EMAIL_CHANGED = 'Email address changed'
+EMAIL_SUBJECT_USER_SPAM_REPORT = 'Spam/offensive report for user'
+EMAIL_SUBJECT_DONATION_THANK_YOU = 'Thanks for your donation!'
+EMAIL_SUBJECT_DONATION_REMINDER = 'Thanks for contributing to Freesound'
+EMAIL_SUBJECT_DONATION_REQUEST = 'Have you considered making a donation?'
+EMAIL_SUBJECT_STREAM_EMAILS = 'New sounds from users and tags you are following'
+EMAIL_SUBJECT_TOPIC_REPLY = 'Topic reply notification'
+EMAIL_SUBJECT_PRIVATE_MESSAGE = 'You have a private message'
+EMAIL_SUBJECT_SOUND_ADDED_AS_REMIX = 'Sound added as remix source'
+EMAIL_SUBJECT_RANDOM_SOUND_OF_THE_SAY_CHOOSEN = 'One of your sounds has been chosen as random sound of the day!'
+EMAIL_SUBJECT_NEW_COMMENT = 'You have a new comment'
+EMAIL_SUBJECT_SOUND_FLAG = 'Sound flag'
+EMAIL_SUBJECT_SUPPORT_EMAIL = '[support]'
+EMAIL_SUBJECT_MODERATION_HANDLED = 'A Freesound moderator handled your upload'
# -------------------------------------------------------------------------------
# Media paths, URLS and static settings
diff --git a/freesound/urls.py b/freesound/urls.py
index 77fbd21952..2512d18f09 100644
--- a/freesound/urls.py
+++ b/freesound/urls.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
#
# Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA
#
diff --git a/general/admin.py b/general/admin.py
index 0a79add1d7..dadcf09702 100644
--- a/general/admin.py
+++ b/general/admin.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
#
# Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA
#
diff --git a/general/management/commands/build_static.py b/general/management/commands/build_static.py
index 1baf342318..83059a1760 100644
--- a/general/management/commands/build_static.py
+++ b/general/management/commands/build_static.py
@@ -38,7 +38,7 @@ def handle(self, **options):
the functionality of passing Django settings as env variables below might not be used.
"""
variables = {}
- variables_for_command = ' '.join(['{0}={1}'.format(key, value) for key, value in variables.items()])
+ variables_for_command = ' '.join(['{}={}'.format(key, value) for key, value in variables.items()])
build_static_command = variables_for_command + ' npm run build'
console_logger.info('Building static files with command:\n' + build_static_command)
os.system(build_static_command)
diff --git a/general/management/commands/clean_data_volume.py b/general/management/commands/clean_data_volume.py
index 32228bd3d1..7a7e71370f 100644
--- a/general/management/commands/clean_data_volume.py
+++ b/general/management/commands/clean_data_volume.py
@@ -99,8 +99,7 @@ def handle(self, **options):
if not files_in_folder:
should_delete = True
else:
- # NOTE: add u''.format(x) below to avoid issues with filenames with non-ascii characters. This can probably be removed when fully migrating to py3
- if all([datetime.datetime.fromtimestamp(os.path.getmtime(os.path.join(folderpath, u''.format(sound_filename)))) < one_year_ago for sound_filename in files_in_folder]):
+ if all([datetime.datetime.fromtimestamp(os.path.getmtime(os.path.join(folderpath, sound_filename))) < one_year_ago for sound_filename in files_in_folder]):
should_delete = True
if should_delete:
# Delete directory and contents
diff --git a/general/management/commands/post_sounds_to_tagrecommendation.py b/general/management/commands/post_sounds_to_tagrecommendation.py
index 42d0be3525..b3f4856d70 100644
--- a/general/management/commands/post_sounds_to_tagrecommendation.py
+++ b/general/management/commands/post_sounds_to_tagrecommendation.py
@@ -18,7 +18,6 @@
# See AUTHORS file.
#
-from __future__ import print_function
from django.core.management.base import BaseCommand
diff --git a/general/management/commands/prune_database.py b/general/management/commands/prune_database.py
index 493b3c3003..3cf7cc9d72 100644
--- a/general/management/commands/prune_database.py
+++ b/general/management/commands/prune_database.py
@@ -18,9 +18,7 @@
# See AUTHORS file.
#
-from __future__ import print_function
-from builtins import range
import logging
import random
diff --git a/general/management/commands/similarity_update.py b/general/management/commands/similarity_update.py
index a8aab2194f..962431af67 100644
--- a/general/management/commands/similarity_update.py
+++ b/general/management/commands/similarity_update.py
@@ -18,7 +18,6 @@
# See AUTHORS file.
#
-from builtins import str
import logging
from django.conf import settings
diff --git a/general/migrations/0001_initial.py b/general/migrations/0001_initial.py
index 1e72c491f5..c839b21c34 100644
--- a/general/migrations/0001_initial.py
+++ b/general/migrations/0001_initial.py
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
# Generated by Django 1.9.5 on 2016-04-15 11:33
-from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
diff --git a/general/models.py b/general/models.py
index 6df8e8e8ee..b3a67b8122 100644
--- a/general/models.py
+++ b/general/models.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
#
# Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA
#
@@ -20,7 +18,6 @@
# See AUTHORS file.
#
-from builtins import object
from comments.models import Comment
from django.contrib.auth.models import User
from django.contrib.contenttypes import fields
@@ -35,7 +32,7 @@ class SocialModel(models.Model):
tags = fields.GenericRelation(TaggedItem)
fans = fields.GenericRelation(Favorite)
- class Meta(object):
+ class Meta:
abstract = True
class AkismetSpam(SocialModel):
@@ -52,7 +49,7 @@ def save(self, *args, **kwargs):
self.order = self.__class__.objects.all().order_by("-order")[0].order + 1
except IndexError:
self.order = 0
- super(OrderedModel, self).save(*args, **kwargs)
+ super().save(*args, **kwargs)
def change_order(self):
model_type_id = ContentType.objects.get_for_model(self.__class__).id
@@ -87,6 +84,6 @@ def move(direction, model_type_id, model_id):
except ModelClass.DoesNotExist:
pass
- class Meta(object):
+ class Meta:
ordering = ["order"]
abstract = True
diff --git a/general/tasks.py b/general/tasks.py
index ca6a487daf..3e61f0cd26 100644
--- a/general/tasks.py
+++ b/general/tasks.py
@@ -17,7 +17,6 @@
# Authors:
# See AUTHORS file.
#
-from builtins import str
import datetime
import hashlib
import json
diff --git a/general/templatetags/absurl.py b/general/templatetags/absurl.py
index 88dfdf7104..6fcc167b54 100644
--- a/general/templatetags/absurl.py
+++ b/general/templatetags/absurl.py
@@ -29,7 +29,7 @@
class AbsoluteURLNode(URLNode):
def render(self, context):
- path = super(AbsoluteURLNode, self).render(context)
+ path = super().render(context)
domain = "https://%s" % Site.objects.get_current().domain
return urllib.parse.urljoin(domain, path)
diff --git a/general/templatetags/bw_templatetags.py b/general/templatetags/bw_templatetags.py
index 37a82605b6..b99f31455e 100644
--- a/general/templatetags/bw_templatetags.py
+++ b/general/templatetags/bw_templatetags.py
@@ -18,9 +18,6 @@
# See AUTHORS file.
#
-from builtins import str
-from builtins import zip
-from builtins import range
import math
from django import template
diff --git a/general/templatetags/filter_img.py b/general/templatetags/filter_img.py
index 656ada0f03..bbec36ecd6 100644
--- a/general/templatetags/filter_img.py
+++ b/general/templatetags/filter_img.py
@@ -1,4 +1,3 @@
-from builtins import str
from django import template
from bs4 import BeautifulSoup
diff --git a/general/templatetags/paginator.py b/general/templatetags/paginator.py
index d8ee47746b..af0d5b48e5 100644
--- a/general/templatetags/paginator.py
+++ b/general/templatetags/paginator.py
@@ -20,8 +20,6 @@
from future import standard_library
standard_library.install_aliases()
-from builtins import str
-from builtins import range
import urllib.request, urllib.parse, urllib.error
from django import template
@@ -57,14 +55,14 @@ def show_paginator(
min_page_num -= min(total_wanted - num_items, paginator.num_pages - num_items)
# although paginator objects are 0-based, we use 1-based paging
- page_numbers = [n for n in range(min_page_num, max_page_num) if n > 0 and n <= paginator.num_pages]
+ page_numbers = [n for n in range(min_page_num, max_page_num) if 0 < n <= paginator.num_pages]
params = urllib.parse.urlencode([(key.encode('utf-8'), value.encode('utf-8')) for (key, value) in request.GET.items()
- if key.lower() != u"page"])
+ if key.lower() != "page"])
if params == "":
- url = request.path + u"?page="
+ url = request.path + "?page="
else:
- url = request.path + u"?" + params + u"&page="
+ url = request.path + "?" + params + "&page="
# The pagination could be over a queryset or over the result of a query to solr, so 'page' could be an object
# if it's the case a query to the DB or a dict if it's the case of a query to solr
diff --git a/general/templatetags/util.py b/general/templatetags/util.py
index 3950ec8eee..7ac82c851b 100644
--- a/general/templatetags/util.py
+++ b/general/templatetags/util.py
@@ -1,4 +1,3 @@
-from __future__ import division
#
# Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA
#
@@ -19,7 +18,6 @@
# See AUTHORS file.
#
-from builtins import range
from past.utils import old_div
import datetime
import time
@@ -39,7 +37,7 @@ def tuple_to_time(t):
@stringfilter
def truncate_string(value, length):
if len(value) > length:
- return value[:length-3] + u"..."
+ return value[:length-3] + "..."
else:
return value
diff --git a/general/tests.py b/general/tests.py
index bae1633c34..1337716d5f 100644
--- a/general/tests.py
+++ b/general/tests.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
#
# Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA
#
@@ -142,7 +140,7 @@ def test_url_with_non_ascii_characters(self):
or values, paginator does not break.
"""
context = {'media_url': 'fake URL'}
- text_with_non_ascii = u'�textèé'
+ text_with_non_ascii = '�textèé'
dummy_request = RequestFactory().get(reverse('sounds'), {
text_with_non_ascii: '1',
'param_name': text_with_non_ascii,
diff --git a/geotags/admin.py b/geotags/admin.py
index d5032ac7da..77486a7cb3 100644
--- a/geotags/admin.py
+++ b/geotags/admin.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
#
# Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA
#
diff --git a/geotags/migrations/0001_initial.py b/geotags/migrations/0001_initial.py
index c5ee6c3063..fe46a8daf4 100644
--- a/geotags/migrations/0001_initial.py
+++ b/geotags/migrations/0001_initial.py
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
# Generated by Django 1.9.5 on 2016-04-15 11:33
-from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
diff --git a/geotags/migrations/0002_auto_20220111_1251.py b/geotags/migrations/0002_auto_20220111_1251.py
index 7a4f5c007f..75493ad653 100644
--- a/geotags/migrations/0002_auto_20220111_1251.py
+++ b/geotags/migrations/0002_auto_20220111_1251.py
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2022-01-11 12:51
-from __future__ import unicode_literals
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
diff --git a/geotags/migrations/0003_geotag_location_name.py b/geotags/migrations/0003_geotag_location_name.py
index 42df150655..560d82ab1b 100644
--- a/geotags/migrations/0003_geotag_location_name.py
+++ b/geotags/migrations/0003_geotag_location_name.py
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2022-01-11 13:01
-from __future__ import unicode_literals
from django.db import migrations, models
diff --git a/geotags/migrations/0004_auto_20230201_1102.py b/geotags/migrations/0004_auto_20230201_1102.py
index 3228e18472..ea110b96a0 100644
--- a/geotags/migrations/0004_auto_20230201_1102.py
+++ b/geotags/migrations/0004_auto_20230201_1102.py
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2023-02-01 11:02
-from __future__ import unicode_literals
from django.db import migrations, models
diff --git a/geotags/models.py b/geotags/models.py
index 62c015b5af..ca4636aeb5 100644
--- a/geotags/models.py
+++ b/geotags/models.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
#
# Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA
#
@@ -43,7 +41,7 @@ class GeoTag(models.Model):
created = models.DateTimeField(db_index=True, auto_now_add=True)
def __str__(self):
- return u"%s (%f,%f)" % (self.user, self.lat, self.lon)
+ return "%s (%f,%f)" % (self.user, self.lat, self.lon)
def get_absolute_url(self):
return reverse('geotag', args=[smart_text(self.id)])
diff --git a/geotags/tests.py b/geotags/tests.py
index 77ed65b6a4..911ad3f49f 100644
--- a/geotags/tests.py
+++ b/geotags/tests.py
@@ -1,4 +1,3 @@
-from __future__ import division
#
# Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA
#
@@ -79,7 +78,7 @@ def test_geotags_infowindow(self):
sound.save()
resp = self.client.get(reverse('geotags-infowindow', kwargs={'sound_id': sound.id}))
self.check_context(resp.context, {'sound': sound})
- self.assertContains(resp, 'href="/people/{0}/sounds/{1}/"'.format(sound.user.username, sound.id))
+ self.assertContains(resp, 'href="/people/{}/sounds/{}/"'.format(sound.user.username, sound.id))
def test_browse_geotags_case_insensitive(self):
user = User.objects.get(username='Anton')
diff --git a/geotags/urls.py b/geotags/urls.py
index ab5825b359..59a946a7e0 100644
--- a/geotags/urls.py
+++ b/geotags/urls.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
#
# Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA
#
diff --git a/messages/admin.py b/messages/admin.py
index 131b2f16ce..3125ffcff7 100644
--- a/messages/admin.py
+++ b/messages/admin.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
#
# Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA
#
diff --git a/messages/forms.py b/messages/forms.py
index 81cf4cfd26..dc1eca1e17 100644
--- a/messages/forms.py
+++ b/messages/forms.py
@@ -44,7 +44,7 @@ class MessageReplyForm(forms.Form):
def __init__(self, request, *args, **kwargs):
self.request = request # This is used by MessageReplyFormWithCaptcha to be able to call is_spam function
- super(MessageReplyForm, self).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
class MessageReplyFormWithCaptcha(MessageReplyForm):
@@ -62,7 +62,7 @@ class BwMessageReplyForm(MessageReplyForm):
def __init__(self, *args, **kwargs):
kwargs.update(dict(label_suffix=''))
- super(BwMessageReplyForm, self).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
html_tags_help_text = """Allowed HTML tags: a
, img
, strong
,
b
, em
, li
, u
, p
, br
,
@@ -84,7 +84,7 @@ class BwMessageReplyFormWithCaptcha(MessageReplyFormWithCaptcha):
def __init__(self, *args, **kwargs):
kwargs.update(dict(label_suffix=''))
- super(BwMessageReplyFormWithCaptcha, self).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
html_tags_help_text = """Allowed HTML tags: a
, img
, strong
,
b
, em
, li
, u
, p
, br
,
diff --git a/messages/migrations/0001_initial.py b/messages/migrations/0001_initial.py
index 1af7809bed..6b333d380b 100644
--- a/messages/migrations/0001_initial.py
+++ b/messages/migrations/0001_initial.py
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
# Generated by Django 1.9.5 on 2016-04-15 11:33
-from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
diff --git a/messages/models.py b/messages/models.py
index 43f82e6f1c..c1a8582f05 100644
--- a/messages/models.py
+++ b/messages/models.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
#
# Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA
#
@@ -20,7 +18,6 @@
# See AUTHORS file.
#
-from builtins import object
from django.contrib.auth.models import User
from django.db import models
from django.utils.encoding import smart_text
@@ -30,7 +27,7 @@ class MessageBody(models.Model):
body = models.TextField()
def __str__(self):
- return self.body[0:30] + u"[...]"
+ return self.body[0:30] + "[...]"
class Message(models.Model):
@@ -102,7 +99,7 @@ def get_absolute_url(self):
return "message", (smart_text(self.id),)
def __str__(self):
- return u"from: [%s] to: [%s]" % (self.user_from, self.user_to)
+ return "from: [%s] to: [%s]" % (self.user_from, self.user_to)
- class Meta(object):
+ class Meta:
ordering = ('-created',)
diff --git a/messages/templatetags/display_message.py b/messages/templatetags/display_message.py
index a12557fce1..9d71506f22 100644
--- a/messages/templatetags/display_message.py
+++ b/messages/templatetags/display_message.py
@@ -18,7 +18,6 @@
# See AUTHORS file.
#
-from __future__ import absolute_import
from django import template
@@ -35,4 +34,3 @@ def display_message(context, message):
'hide_archive_unarchive': context.get('hide_archive_unarchive', False),
'list_type': context['list_type']
}
-
\ No newline at end of file
diff --git a/messages/tests/test_message_notifications.py b/messages/tests/test_message_notifications.py
index 684f271919..bdc8baeb9f 100644
--- a/messages/tests/test_message_notifications.py
+++ b/messages/tests/test_message_notifications.py
@@ -43,9 +43,9 @@ def setUp(self):
def test_message_email_preference_enabled(self, magic_mock):
self.client.force_login(user=self.sender)
resp = self.client.post(reverse('messages-new'), data={
- u'body': [u'test message body'],
- u'to': [u'receiver'],
- u'subject': [u'test message'],
+ 'body': ['test message body'],
+ 'to': ['receiver'],
+ 'subject': ['test message'],
})
self.assertRedirects(resp, reverse('messages'))
self.assertEqual(len(mail.outbox), 1)
@@ -61,9 +61,9 @@ def test_message_email_preference_disabled(self, magic_mock):
self.client.force_login(user=self.sender)
resp = self.client.post(reverse('messages-new'), data={
- u'body': [u'test message body'],
- u'to': [u'receiver'],
- u'subject': [u'test message'],
+ 'body': ['test message body'],
+ 'to': ['receiver'],
+ 'subject': ['test message'],
})
self.assertRedirects(resp, reverse('messages'))
self.assertEqual(len(mail.outbox), 0)
diff --git a/messages/tests/test_message_write.py b/messages/tests/test_message_write.py
index 161fc2de82..9d340f20dd 100644
--- a/messages/tests/test_message_write.py
+++ b/messages/tests/test_message_write.py
@@ -17,10 +17,8 @@
# Authors:
# See AUTHORS file.
#
-from builtins import range
import json
-import six
from django.contrib.auth.models import User
from django.test import TestCase
from django.urls import reverse
@@ -113,7 +111,7 @@ def test_username_lookup_num_queries(self):
def test_get_previously_contacted_usernames(self):
# Check get_previously_contacted_usernames helper function returns userames of users previously contacted by
# the sender or users who previously contacted the sender
- six.assertCountEqual(self, [self.receiver3.username, self.receiver2.username, self.receiver1.username,
+ self.assertCountEqual([self.receiver3.username, self.receiver2.username, self.receiver1.username,
self.sender2.username, self.sender.username],
get_previously_contacted_usernames(self.sender))
@@ -124,7 +122,7 @@ def test_username_lookup_response(self):
resp = self.client.get(reverse('messages-username_lookup'))
response_json = json.loads(resp.content)
self.assertEqual(resp.status_code, 200)
- six.assertCountEqual(self, [self.receiver3.username, self.receiver2.username, self.receiver1.username,
+ self.assertCountEqual([self.receiver3.username, self.receiver2.username, self.receiver1.username,
self.sender2.username, self.sender.username],
response_json)
diff --git a/messages/views.py b/messages/views.py
index 7212c106e0..8d13afefab 100644
--- a/messages/views.py
+++ b/messages/views.py
@@ -225,7 +225,7 @@ def get_previously_contacted_usernames(user):
usernames = list(Message.objects.select_related('user_from', 'user_to')
.filter(Q(user_from=user) | Q(user_to=user))
.values_list('user_to__username', 'user_from__username'))
- return list(set([item for sublist in usernames for item in sublist]))
+ return list({item for sublist in usernames for item in sublist})
@login_required
diff --git a/monitor/management/commands/generate_stats.py b/monitor/management/commands/generate_stats.py
index 43b7cf88a5..0c3de82f79 100644
--- a/monitor/management/commands/generate_stats.py
+++ b/monitor/management/commands/generate_stats.py
@@ -18,7 +18,6 @@
# See AUTHORS file.
#
-from builtins import str
import datetime
from django.contrib.auth.models import User
diff --git a/monitor/models.py b/monitor/models.py
index bd4b2abe9e..71a8362390 100644
--- a/monitor/models.py
+++ b/monitor/models.py
@@ -1,5 +1,3 @@
-from __future__ import unicode_literals
-
from django.db import models
# Create your models here.
diff --git a/monitor/views.py b/monitor/views.py
index f0bf19d24a..e5fe0e7237 100644
--- a/monitor/views.py
+++ b/monitor/views.py
@@ -1,4 +1,3 @@
-from __future__ import division
#
# Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA
#
diff --git a/ratings/admin.py b/ratings/admin.py
index c59bf0593a..f7a848ec9a 100644
--- a/ratings/admin.py
+++ b/ratings/admin.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
#
# Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA
#
diff --git a/ratings/migrations/0001_initial.py b/ratings/migrations/0001_initial.py
index 53e987b784..701567dc9d 100644
--- a/ratings/migrations/0001_initial.py
+++ b/ratings/migrations/0001_initial.py
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
# Generated by Django 1.9.5 on 2016-04-15 11:33
-from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
@@ -33,6 +31,6 @@ class Migration(migrations.Migration):
),
migrations.AlterUniqueTogether(
name='rating',
- unique_together=set([('user', 'content_type', 'object_id')]),
+ unique_together={('user', 'content_type', 'object_id')},
),
]
diff --git a/ratings/migrations/0002_rating_sound.py b/ratings/migrations/0002_rating_sound.py
index 0d9792489b..eb2e22d3d0 100644
--- a/ratings/migrations/0002_rating_sound.py
+++ b/ratings/migrations/0002_rating_sound.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
from django.db import migrations, models
from django.conf import settings
import django.db.models.deletion
diff --git a/ratings/models.py b/ratings/models.py
index 2c84351696..862b605cc6 100644
--- a/ratings/models.py
+++ b/ratings/models.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
#
# Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA
#
@@ -20,7 +18,6 @@
# See AUTHORS file.
#
-from builtins import object
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
@@ -40,9 +37,9 @@ class SoundRating(models.Model):
created = models.DateTimeField(db_index=True, auto_now_add=True)
def __str__(self):
- return u"%s rated %s: %d" % (self.user, self.sound, self.rating)
+ return "%s rated %s: %d" % (self.user, self.sound, self.rating)
- class Meta(object):
+ class Meta:
unique_together = (('user', 'sound'),)
ordering = ('-created',)
diff --git a/ratings/urls.py b/ratings/urls.py
index e2063c9211..dc664715d0 100644
--- a/ratings/urls.py
+++ b/ratings/urls.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
#
# Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA
#
diff --git a/ratings/views.py b/ratings/views.py
index 0961fc358c..0fc084b3f2 100644
--- a/ratings/views.py
+++ b/ratings/views.py
@@ -18,7 +18,6 @@
# See AUTHORS file.
#
-from builtins import str
from django.contrib.auth.decorators import login_required
from django.db import transaction
from django.http import Http404
diff --git a/search/forms.py b/search/forms.py
index 34547deb24..f8084af02c 100644
--- a/search/forms.py
+++ b/search/forms.py
@@ -51,5 +51,5 @@ def clean_s(self):
return settings.SEARCH_SOUNDS_SORT_DEFAULT
def __init__(self, sort_options, *args, **kargs):
- super(SoundSearchForm, self).__init__(*args, **kargs)
+ super().__init__(*args, **kargs)
self.sort_options = sort_options
\ No newline at end of file
diff --git a/search/management/commands/post_dirty_sounds_to_search_engine.py b/search/management/commands/post_dirty_sounds_to_search_engine.py
index 07bfa50b24..fa5ba2f156 100644
--- a/search/management/commands/post_dirty_sounds_to_search_engine.py
+++ b/search/management/commands/post_dirty_sounds_to_search_engine.py
@@ -18,7 +18,6 @@
# See AUTHORS file.
#
-from builtins import range
import logging
from sounds.models import Sound
diff --git a/search/management/commands/reindex_search_engine_forum.py b/search/management/commands/reindex_search_engine_forum.py
index d46b0f8cc7..ac2de25754 100644
--- a/search/management/commands/reindex_search_engine_forum.py
+++ b/search/management/commands/reindex_search_engine_forum.py
@@ -18,7 +18,6 @@
# See AUTHORS file.
#
-from builtins import range
import logging
from django.core.management.base import BaseCommand
diff --git a/search/templatetags/search.py b/search/templatetags/search.py
index 5571e4f912..97631e62f8 100644
--- a/search/templatetags/search.py
+++ b/search/templatetags/search.py
@@ -1,4 +1,3 @@
-from __future__ import division
#
# Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA
#
@@ -48,7 +47,7 @@ def display_facet(context, flt, facet, facet_type, title=""):
if element['name'].count("_") > 0:
# We also modify the display name to remove the id
element['display_name'] = element['name'][element['name'].find("_")+1:]
- element['params'] = u'{0} {1}:"{2}"'.format(filter_query, flt, urlquote_plus(element['name']))
+ element['params'] = '{} {}:"{}"'.format(filter_query, flt, urlquote_plus(element['name']))
else:
# If facet element belongs to "grouping pack" filter but does not have the "_" character in it, it
# means this corresponds to the "no pack" grouping which we don't want to show as a facet element.
@@ -56,9 +55,9 @@ def display_facet(context, flt, facet, facet_type, title=""):
else:
element['display_name'] = element['name']
- element['params'] = u'{0} {1}:"{2}"'.format(filter_query, flt, urlquote_plus(element['name']))
- element['id'] = u'{0}--{1}'.format(flt, urlquote_plus(element['name']))
- element['add_filter_url'] = u'.?g={0}&only_p={1}&q={2}&f={3}&s={4}&w={5}'.format(
+ element['params'] = '{} {}:"{}"'.format(filter_query, flt, urlquote_plus(element['name']))
+ element['id'] = '{}--{}'.format(flt, urlquote_plus(element['name']))
+ element['add_filter_url'] = '.?g={}&only_p={}&q={}&f={}&s={}&w={}'.format(
context['group_by_pack_in_request'],
context['only_sounds_with_pack'],
context['search_query'],
diff --git a/search/tests.py b/search/tests.py
index 5fb9a0b0cc..24201a3715 100644
--- a/search/tests.py
+++ b/search/tests.py
@@ -18,7 +18,6 @@
# See AUTHORS file.
#
-from builtins import str
from django.test import TestCase
from django.urls import reverse
from sounds.models import Sound
@@ -196,8 +195,8 @@ def test_successful_search_result_clustering_view(self, cluster_sound_results):
# 3 most used tags in the cluster 'tag1 tag2 tag3'
# context variable cluster_id_num_results_tags_sound_examples: [({0}
'.format(suggestion), 'value': suggestion}) + suggestions.append({'id': count, 'label': '{}
'.format(suggestion), 'value': suggestion}) return JsonResponse({'suggestions': suggestions}) diff --git a/sounds/admin.py b/sounds/admin.py index 9fe2d19793..88b4808e59 100644 --- a/sounds/admin.py +++ b/sounds/admin.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - # # Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA # @@ -57,16 +55,16 @@ class SoundAdmin(DjangoObjectActions, admin.ModelAdmin): change_actions = ('reprocess_sound', ) def get_processing_state(self, obj): - processing_state = u'{}'.format(obj.get_processing_state_display()) + processing_state = '{}'.format(obj.get_processing_state_display()) ongoing_state_display = obj.get_processing_ongoing_state_display() if ongoing_state_display == 'Processing' or ongoing_state_display == 'Queued': - processing_state += u' ({})'.format(ongoing_state_display) + processing_state += ' ({})'.format(ongoing_state_display) return processing_state get_processing_state.short_description = 'Processing state' def get_sound_name(self, obj): max_len = 15 - return u'{0}{1}'.format(obj.original_filename[:max_len], '...' if len(obj.original_filename) > max_len else '') + return '{}{}'.format(obj.original_filename[:max_len], '...' if len(obj.original_filename) > max_len else '') get_sound_name.short_description = 'Name' def reprocess_sound(self, request, queryset_or_object): @@ -95,16 +93,16 @@ class DeletedSoundAdmin(admin.ModelAdmin): def get_queryset(self, request): # Override 'get_queryset' to optimize query by using select_related on appropriate fields - qs = super(DeletedSoundAdmin, self).get_queryset(request) + qs = super().get_queryset(request) qs = qs.select_related('user') return qs def user_link(self, obj): if obj.user is None: return '-' - return '{1}'.format( + return '{}'.format( reverse('admin:auth_user_change', args=[obj.user.id]), - '{0}'.format(obj.user.username)) + '{}'.format(obj.user.username)) user_link.allow_tags = True user_link.admin_order_field = 'user' @@ -127,12 +125,12 @@ class FlagAdmin(admin.ModelAdmin): def get_queryset(self, request): # overrride 'get_queryset' to optimize query by using select_related on 'sound' and 'reporting_user' - qs = super(FlagAdmin, self).get_queryset(request) + qs = super().get_queryset(request) qs = qs.select_related('sound', 'reporting_user') return qs def reporting_user_link(self, obj): - return '{1}'.format( + return '{}'.format( reverse('account', args=[obj.reporting_user.username]), obj.reporting_user.username) \ if obj.reporting_user else '-' reporting_user_link.allow_tags = True @@ -140,21 +138,21 @@ def reporting_user_link(self, obj): reporting_user_link.short_description = 'Reporting User' def email_link(self, obj): - return '{1}'.format(obj.email, obj.email) \ + return '{}'.format(obj.email, obj.email) \ if obj.email else '-' email_link.allow_tags = True email_link.admin_order_field = 'email' email_link.short_description = 'Email' def sound_uploader_link(self, obj): - return '{1}'.format(reverse('account', args=[obj.sound.user.username]), + return '{}'.format(reverse('account', args=[obj.sound.user.username]), obj.sound.user.username) sound_uploader_link.allow_tags = True sound_uploader_link.admin_order_field = 'sound__user__username' sound_uploader_link.short_description = 'Uploader' def sound_link(self, obj): - return '{1}'.format(reverse('short-sound-link', args=[obj.sound_id]), + return '{}'.format(reverse('short-sound-link', args=[obj.sound_id]), truncatechars(obj.sound.base_filename_slug, 50)) sound_link.allow_tags = True sound_link.admin_order_field = 'sound__original_filename' @@ -179,7 +177,7 @@ class SoundOfTheDayAdmin(admin.ModelAdmin): ordering = ('-date_display', ) def get_urls(self): - urls = super(SoundOfTheDayAdmin, self).get_urls() + urls = super().get_urls() my_urls = [ url('generate_new_sounds/', self.generate_new_sounds), url('clear_sound_of_the_day_cache/', self.clear_sound_of_the_day_cache), diff --git a/sounds/forms.py b/sounds/forms.py index a10a3b9afd..f9e50838e2 100644 --- a/sounds/forms.py +++ b/sounds/forms.py @@ -18,11 +18,9 @@ # See AUTHORS file. # -from __future__ import print_function import re -from builtins import object from captcha.fields import ReCaptchaField from django import forms from django.conf import settings @@ -86,7 +84,7 @@ def __init__(self, *args, **kwargs): explicit_disable = kwargs.get('explicit_disable') del kwargs['explicit_disable'] - super(SoundDescriptionForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) # Disable is_explicit field if is already marked self.initial['is_explicit'] = explicit_disable self.fields['is_explicit'].disabled = explicit_disable @@ -97,7 +95,7 @@ class RemixForm(forms.Form): def __init__(self, sound, *args, **kwargs): self.sound = sound - super(RemixForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def clean_sources(self): sources = re.sub("[^0-9,]", "", self.cleaned_data['sources']) @@ -105,7 +103,7 @@ def clean_sources(self): sources = re.sub("^,+", "", sources) sources = re.sub(",+$", "", sources) if len(sources) > 0: - sources = set([int(source) for source in sources.split(",")]) + sources = {int(source) for source in sources.split(",")} else: sources = set() @@ -126,7 +124,7 @@ class PackForm(forms.Form): label="Or fill in the name of a new pack:", required=False, min_length=5) def __init__(self, pack_choices, *args, **kwargs): - super(PackForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.fields['pack'].queryset = pack_choices.extra(select={'lower_name': 'lower(name)'}).order_by('lower_name') @@ -142,13 +140,13 @@ def clean_pack_sounds(self): pack_sounds = re.sub("^,+", "", pack_sounds) pack_sounds = re.sub(",+$", "", pack_sounds) if len(pack_sounds) > 0: - pack_sounds = set([int(sound) for sound in pack_sounds.split(",")]) + pack_sounds = {int(sound) for sound in pack_sounds.split(",")} else: pack_sounds = set() return pack_sounds def save(self, force_insert=False, force_update=False, commit=True): - pack = super(PackEditForm, self).save(commit=False) + pack = super().save(commit=False) affected_packs = list() affected_packs.append(pack) new_sounds = self.cleaned_data['pack_sounds'] @@ -171,7 +169,7 @@ def save(self, force_insert=False, force_update=False, commit=True): affected_pack.process() return pack - class Meta(object): + class Meta: model = Pack fields = ('name', 'description',) widgets = { @@ -186,7 +184,7 @@ class NewLicenseForm(forms.Form): def __init__(self, *args, **kwargs): hide_old_versions = kwargs.pop('hide_old_versions', False) - super(NewLicenseForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) if hide_old_versions: new_qs = License.objects.filter(Q(name__startswith='Attribution') | Q(name__startswith='Creative')).exclude(deed_url__contains="3.0") self.fields['license'].queryset = new_qs @@ -240,7 +238,7 @@ def __init__(self, *args, **kwargs): kwargs['initial'] = { 'encrypted_link': encrypted_link } - super(DeleteSoundForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) class SoundCSVDescriptionForm(SoundDescriptionForm, GeotaggingForm, NewLicenseForm): @@ -254,7 +252,7 @@ class SoundCSVDescriptionForm(SoundDescriptionForm, GeotaggingForm, NewLicenseFo pack_name = forms.CharField(min_length=5, required=False) def __init__(self, *args, **kwargs): - super(SoundCSVDescriptionForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.fields['name'].required = False # Make sound name not required def clean(self): @@ -304,7 +302,7 @@ def __init__(self, *args, **kwargs): explicit_disable = kwargs.pop('explicit_disable', False) hide_old_license_versions = kwargs.pop('hide_old_license_versions', False) user_packs = kwargs.pop('user_packs', False) - super(BWSoundEditAndDescribeForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.fields['is_explicit'].widget.attrs['class'] = 'bw-checkbox' self.fields['remove_geotag'].widget.attrs['class'] = 'bw-checkbox' self.fields['license'].widget.attrs['class'] = 'bw-radio' @@ -354,7 +352,7 @@ def clean_sources(self): sources = re.sub("^,+", "", sources) sources = re.sub(",+$", "", sources) if len(sources) > 0: - sources = set([int(source) for source in sources.split(",")]) + sources = {int(source) for source in sources.split(",")} else: sources = set() return sources \ No newline at end of file diff --git a/sounds/management.py b/sounds/management.py index fbbda4d0f2..edbdb09f9a 100644 --- a/sounds/management.py +++ b/sounds/management.py @@ -18,7 +18,6 @@ # See AUTHORS file. # -from __future__ import print_function import os diff --git a/sounds/management/commands/check_sound_paths.py b/sounds/management/commands/check_sound_paths.py index 75b1ca67b8..91270f6640 100644 --- a/sounds/management/commands/check_sound_paths.py +++ b/sounds/management/commands/check_sound_paths.py @@ -45,8 +45,8 @@ def handle(self, *args, **options): if not os.path.exists(sound.locations('path')): missing_sound_ids += [sound.id] - console_logger.info('Found {0} sounds with missing audio files'.format(len(missing_sound_ids))) + console_logger.info('Found {} sounds with missing audio files'.format(len(missing_sound_ids))) if missing_sound_ids and options['outfile'] is not None: json.dump(missing_sound_ids, open(options['outfile'], 'w')) - console_logger.info('List of sound IDs with missing files saved in "{0}"'.format(options['outfile'])) + console_logger.info('List of sound IDs with missing files saved in "{}"'.format(options['outfile'])) diff --git a/sounds/management/commands/create_random_sounds.py b/sounds/management/commands/create_random_sounds.py index 70f8e59073..88812d32b6 100644 --- a/sounds/management/commands/create_random_sounds.py +++ b/sounds/management/commands/create_random_sounds.py @@ -18,7 +18,6 @@ # See AUTHORS file. # -from builtins import range import datetime from django.conf import settings diff --git a/sounds/management/commands/create_remix_groups.py b/sounds/management/commands/create_remix_groups.py index f63095b1f9..d04579ab07 100644 --- a/sounds/management/commands/create_remix_groups.py +++ b/sounds/management/commands/create_remix_groups.py @@ -18,9 +18,7 @@ # See AUTHORS file. # -from __future__ import division -from builtins import str import json import logging @@ -106,7 +104,7 @@ def _create_and_save_remixgroup(sg, remixgroup): # dict with key=sound_id, value=index, nodeName=original_filname # in the previous sorted by date list # FIXME: no need for all this data, can be simple dict, key=value - container = dict((val[0], {'index': idx, 'nodeName': val[1]['nodeName']}) for (idx, val) in enumerate(node_list)) + container = {val[0]: {'index': idx, 'nodeName': val[1]['nodeName']} for (idx, val) in enumerate(node_list)} # print ' ========== CONTAINER ========= ' # pp(container) diff --git a/sounds/management/commands/orchestrate_analysis.py b/sounds/management/commands/orchestrate_analysis.py index 7fdf9cf5c1..8badd93780 100644 --- a/sounds/management/commands/orchestrate_analysis.py +++ b/sounds/management/commands/orchestrate_analysis.py @@ -17,7 +17,6 @@ # Authors: # See AUTHORS file. # -from builtins import str import datetime import logging import json @@ -79,8 +78,8 @@ def handle(self, *args, **options): percentage_done = (ok + sk + fa) * 100.0/n_sounds # print one row per analyzer console_logger.info("{: >44} {: >11} {: >11} {: >11} {: >11} {: >11}".format( - *[analyzer_name + ' |', '{0} |'.format(ok), '{0} |'.format(sk), - '{0} |'.format(fa), '{0} |'.format(qu), missing])) + *[analyzer_name + ' |', '{} |'.format(ok), '{} |'.format(sk), + '{} |'.format(fa), '{} |'.format(qu), missing])) data_to_log[analyzer_name] = { 'OK': ok, @@ -174,7 +173,7 @@ def handle(self, *args, **options): 'analyzer': analyzer_name, 'percentage_completed': analyzer_data_to_log['Percentage'] }) - commands_logger.info('Orchestrate analysis analyzer update ({0})'.format(json.dumps(analyzer_data_to_log))) + commands_logger.info('Orchestrate analysis analyzer update ({})'.format(json.dumps(analyzer_data_to_log))) console_logger.info('') # Now revise SoundAnalysis objects that have been stuck in QU status for some time and set them to Failed diff --git a/sounds/management/commands/update_cdn_sounds.py b/sounds/management/commands/update_cdn_sounds.py index 00a45e589a..0670f53528 100644 --- a/sounds/management/commands/update_cdn_sounds.py +++ b/sounds/management/commands/update_cdn_sounds.py @@ -18,7 +18,6 @@ # See AUTHORS file. # -from builtins import str import json import logging import os diff --git a/sounds/migrations/0001_initial.py b/sounds/migrations/0001_initial.py index 70d056026e..772992c680 100644 --- a/sounds/migrations/0001_initial.py +++ b/sounds/migrations/0001_initial.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.9.5 on 2016-04-15 11:33 -from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models @@ -167,6 +165,6 @@ class Migration(migrations.Migration): ), migrations.AlterUniqueTogether( name='pack', - unique_together=set([('user', 'name')]), + unique_together={('user', 'name')}, ), ] diff --git a/sounds/migrations/0002_auto_20160728_1516.py b/sounds/migrations/0002_auto_20160728_1516.py index a7db8e17e7..3afcc91df4 100644 --- a/sounds/migrations/0002_auto_20160728_1516.py +++ b/sounds/migrations/0002_auto_20160728_1516.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.9.5 on 2016-07-28 15:16 -from __future__ import unicode_literals import django.contrib.postgres.fields.jsonb from django.db import migrations, models diff --git a/sounds/migrations/0003_auto_20160914_1100.py b/sounds/migrations/0003_auto_20160914_1100.py index ea8a79efd6..ed0748a723 100644 --- a/sounds/migrations/0003_auto_20160914_1100.py +++ b/sounds/migrations/0003_auto_20160914_1100.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.9.5 on 2016-09-14 11:00 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/sounds/migrations/0004_deletedsound_created.py b/sounds/migrations/0004_deletedsound_created.py index 369cdafae3..5b93352a1b 100644 --- a/sounds/migrations/0004_deletedsound_created.py +++ b/sounds/migrations/0004_deletedsound_created.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.9.5 on 2016-09-19 09:52 -from __future__ import unicode_literals import datetime from django.db import migrations, models diff --git a/sounds/migrations/0005_auto_20161004_1500.py b/sounds/migrations/0005_auto_20161004_1500.py index dde5a382b3..e901196e98 100644 --- a/sounds/migrations/0005_auto_20161004_1500.py +++ b/sounds/migrations/0005_auto_20161004_1500.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.9.5 on 2016-10-04 15:00 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/sounds/migrations/0006_auto_20161005_1533.py b/sounds/migrations/0006_auto_20161005_1533.py index 0f6eb1e5f8..0ae6804c89 100644 --- a/sounds/migrations/0006_auto_20161005_1533.py +++ b/sounds/migrations/0006_auto_20161005_1533.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.9.5 on 2016-10-05 15:33 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/sounds/migrations/0007_auto_20161018_1809.py b/sounds/migrations/0007_auto_20161018_1809.py index efa1bfdd82..72d8f90f32 100644 --- a/sounds/migrations/0007_auto_20161018_1809.py +++ b/sounds/migrations/0007_auto_20161018_1809.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.9.5 on 2016-10-18 18:09 -from __future__ import unicode_literals from django.db import migrations, models @@ -19,6 +17,6 @@ class Migration(migrations.Migration): ), migrations.AlterUniqueTogether( name='pack', - unique_together=set([('user', 'name', 'is_deleted')]), + unique_together={('user', 'name', 'is_deleted')}, ), ] diff --git a/sounds/migrations/0008_soundoftheday.py b/sounds/migrations/0008_soundoftheday.py index 55db688763..6632c3abff 100644 --- a/sounds/migrations/0008_soundoftheday.py +++ b/sounds/migrations/0008_soundoftheday.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2017-06-20 16:47 -from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion diff --git a/sounds/migrations/0009_download_license.py b/sounds/migrations/0009_download_license.py index fdcd0c6b38..4bf5671067 100644 --- a/sounds/migrations/0009_download_license.py +++ b/sounds/migrations/0009_download_license.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2017-07-12 12:53 -from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion diff --git a/sounds/migrations/0010_auto_20170712_1537.py b/sounds/migrations/0010_auto_20170712_1537.py index 96ba3f3071..b54ec5a68f 100644 --- a/sounds/migrations/0010_auto_20170712_1537.py +++ b/sounds/migrations/0010_auto_20170712_1537.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2017-07-12 15:37 -from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion diff --git a/sounds/migrations/0011_auto_20170928_1441.py b/sounds/migrations/0011_auto_20170928_1441.py index 1880db87b4..c369c5343b 100644 --- a/sounds/migrations/0011_auto_20170928_1441.py +++ b/sounds/migrations/0011_auto_20170928_1441.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2017-09-28 14:41 -from __future__ import unicode_literals from django.db import migrations diff --git a/sounds/migrations/0012_auto_20171002_1710.py b/sounds/migrations/0012_auto_20171002_1710.py index 345364f095..9221b9e8a8 100644 --- a/sounds/migrations/0012_auto_20171002_1710.py +++ b/sounds/migrations/0012_auto_20171002_1710.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2017-10-02 17:10 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/sounds/migrations/0013_remove_triggers.py b/sounds/migrations/0013_remove_triggers.py index b1bd3ffbbd..08765b487f 100644 --- a/sounds/migrations/0013_remove_triggers.py +++ b/sounds/migrations/0013_remove_triggers.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2017-10-05 12:53 -from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion diff --git a/sounds/migrations/0014_auto_20171124_1628.py b/sounds/migrations/0014_auto_20171124_1628.py index d2211ce82f..ea257fcc47 100644 --- a/sounds/migrations/0014_auto_20171124_1628.py +++ b/sounds/migrations/0014_auto_20171124_1628.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2017-11-24 16:28 -from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion diff --git a/sounds/migrations/0014_packdownload_packdownloadjson_packdownloadsound.py b/sounds/migrations/0014_packdownload_packdownloadjson_packdownloadsound.py index 45be80c4fa..c0478e01ab 100644 --- a/sounds/migrations/0014_packdownload_packdownloadjson_packdownloadsound.py +++ b/sounds/migrations/0014_packdownload_packdownloadjson_packdownloadsound.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2017-11-22 12:38 -from __future__ import unicode_literals from django.conf import settings import django.contrib.postgres.fields.jsonb diff --git a/sounds/migrations/0015_auto_20171124_1651.py b/sounds/migrations/0015_auto_20171124_1651.py index c17e4f4674..fa34831908 100644 --- a/sounds/migrations/0015_auto_20171124_1651.py +++ b/sounds/migrations/0015_auto_20171124_1651.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2017-11-24 16:51 -from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion diff --git a/sounds/migrations/0016_merge_20171201_1822.py b/sounds/migrations/0016_merge_20171201_1822.py index 891e92fd1f..64ad6a8baf 100644 --- a/sounds/migrations/0016_merge_20171201_1822.py +++ b/sounds/migrations/0016_merge_20171201_1822.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2017-12-01 18:22 -from __future__ import unicode_literals from django.db import migrations diff --git a/sounds/migrations/0017_auto_20180117_1553.py b/sounds/migrations/0017_auto_20180117_1553.py index 0db9a65a59..407decd147 100644 --- a/sounds/migrations/0017_auto_20180117_1553.py +++ b/sounds/migrations/0017_auto_20180117_1553.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2018-01-17 15:53 -from __future__ import unicode_literals from django.db import migrations diff --git a/sounds/migrations/0018_auto_20180209_1540.py b/sounds/migrations/0018_auto_20180209_1540.py index 13f6368bf0..f64c27c192 100644 --- a/sounds/migrations/0018_auto_20180209_1540.py +++ b/sounds/migrations/0018_auto_20180209_1540.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2018-02-09 15:40 -from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion diff --git a/sounds/migrations/0019_bulkuploadprogress.py b/sounds/migrations/0019_bulkuploadprogress.py index 5a694d2350..86aa40431c 100644 --- a/sounds/migrations/0019_bulkuploadprogress.py +++ b/sounds/migrations/0019_bulkuploadprogress.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2018-01-03 15:06 -from __future__ import unicode_literals from django.conf import settings import django.contrib.postgres.fields.jsonb diff --git a/sounds/migrations/0019_remove_download_pack.py b/sounds/migrations/0019_remove_download_pack.py index f884b03707..13706c9c10 100644 --- a/sounds/migrations/0019_remove_download_pack.py +++ b/sounds/migrations/0019_remove_download_pack.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2018-02-09 15:52 -from __future__ import unicode_literals from django.db import migrations diff --git a/sounds/migrations/0020_update_download_indexes.py b/sounds/migrations/0020_update_download_indexes.py index 1cde3a10ed..4d43d71b2d 100644 --- a/sounds/migrations/0020_update_download_indexes.py +++ b/sounds/migrations/0020_update_download_indexes.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2018-03-20 15:16 -from __future__ import unicode_literals from django.db import migrations diff --git a/sounds/migrations/0021_auto_20180320_1554.py b/sounds/migrations/0021_auto_20180320_1554.py index 36135f7adb..eeea4761b3 100644 --- a/sounds/migrations/0021_auto_20180320_1554.py +++ b/sounds/migrations/0021_auto_20180320_1554.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2018-03-20 15:54 -from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion diff --git a/sounds/migrations/0022_auto_20180321_1048.py b/sounds/migrations/0022_auto_20180321_1048.py index 23e142092e..a11c7fd12d 100644 --- a/sounds/migrations/0022_auto_20180321_1048.py +++ b/sounds/migrations/0022_auto_20180321_1048.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2018-03-21 10:48 -from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion diff --git a/sounds/migrations/0023_auto_20180322_1129.py b/sounds/migrations/0023_auto_20180322_1129.py index 748fd7b11c..288855c2e4 100644 --- a/sounds/migrations/0023_auto_20180322_1129.py +++ b/sounds/migrations/0023_auto_20180322_1129.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2018-03-22 11:29 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/sounds/migrations/0024_auto_20180503_1326.py b/sounds/migrations/0024_auto_20180503_1326.py index d408d02913..ba1d1c4d64 100644 --- a/sounds/migrations/0024_auto_20180503_1326.py +++ b/sounds/migrations/0024_auto_20180503_1326.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2018-05-03 13:26 -from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models diff --git a/sounds/migrations/0024_merge_20180403_1616.py b/sounds/migrations/0024_merge_20180403_1616.py index 82860f89ae..06b91adf42 100644 --- a/sounds/migrations/0024_merge_20180403_1616.py +++ b/sounds/migrations/0024_merge_20180403_1616.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2018-04-03 16:16 -from __future__ import unicode_literals from django.db import migrations diff --git a/sounds/migrations/0025_bulkuploadprogress_original_csv_filename.py b/sounds/migrations/0025_bulkuploadprogress_original_csv_filename.py index ed37ff5258..2881ac7e25 100644 --- a/sounds/migrations/0025_bulkuploadprogress_original_csv_filename.py +++ b/sounds/migrations/0025_bulkuploadprogress_original_csv_filename.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2018-04-04 16:14 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/sounds/migrations/0026_auto_20180404_1652.py b/sounds/migrations/0026_auto_20180404_1652.py index 5654b30538..042837d8e8 100644 --- a/sounds/migrations/0026_auto_20180404_1652.py +++ b/sounds/migrations/0026_auto_20180404_1652.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2018-04-04 16:52 -from __future__ import unicode_literals from django.db import migrations diff --git a/sounds/migrations/0027_auto_20180406_1208.py b/sounds/migrations/0027_auto_20180406_1208.py index 24a0dacb8a..d5460a1fc6 100644 --- a/sounds/migrations/0027_auto_20180406_1208.py +++ b/sounds/migrations/0027_auto_20180406_1208.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2018-04-06 12:08 -from __future__ import unicode_literals import django.contrib.postgres.fields.jsonb from django.db import migrations, models diff --git a/sounds/migrations/0028_auto_20180411_1634.py b/sounds/migrations/0028_auto_20180411_1634.py index 97ad390600..427764ea4a 100644 --- a/sounds/migrations/0028_auto_20180411_1634.py +++ b/sounds/migrations/0028_auto_20180411_1634.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2018-04-11 16:34 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/sounds/migrations/0029_merge_20180510_1627.py b/sounds/migrations/0029_merge_20180510_1627.py index 490b0ab594..b0fea04051 100644 --- a/sounds/migrations/0029_merge_20180510_1627.py +++ b/sounds/migrations/0029_merge_20180510_1627.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2018-05-10 16:27 -from __future__ import unicode_literals from django.db import migrations diff --git a/sounds/migrations/0030_auto_20180618_1305.py b/sounds/migrations/0030_auto_20180618_1305.py index 16c55e532a..26ef1b0b9f 100644 --- a/sounds/migrations/0030_auto_20180618_1305.py +++ b/sounds/migrations/0030_auto_20180618_1305.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2018-06-18 13:05 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/sounds/migrations/0031_soundanalysis.py b/sounds/migrations/0031_soundanalysis.py index 2b6dd35d2f..ac2ca149f2 100644 --- a/sounds/migrations/0031_soundanalysis.py +++ b/sounds/migrations/0031_soundanalysis.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2018-09-05 11:53 -from __future__ import unicode_literals import django.contrib.postgres.fields.jsonb from django.db import migrations, models diff --git a/sounds/migrations/0032_auto_20180905_1301.py b/sounds/migrations/0032_auto_20180905_1301.py index f474dac3ac..45b7df3b7b 100644 --- a/sounds/migrations/0032_auto_20180905_1301.py +++ b/sounds/migrations/0032_auto_20180905_1301.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2018-09-05 13:01 -from __future__ import unicode_literals from django.db import migrations @@ -14,6 +12,6 @@ class Migration(migrations.Migration): operations = [ migrations.AlterUniqueTogether( name='soundanalysis', - unique_together=set([('sound', 'extractor')]), + unique_together={('sound', 'extractor')}, ), ] diff --git a/sounds/migrations/0033_auto_20190528_1554.py b/sounds/migrations/0033_auto_20190528_1554.py index 17b6596a6c..72aa47d533 100644 --- a/sounds/migrations/0033_auto_20190528_1554.py +++ b/sounds/migrations/0033_auto_20190528_1554.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-05-28 15:54 -from __future__ import unicode_literals from django.db import migrations diff --git a/sounds/migrations/0034_make_latest_index_20190712_1616.py b/sounds/migrations/0034_make_latest_index_20190712_1616.py index 7658856452..8baae8dfff 100644 --- a/sounds/migrations/0034_make_latest_index_20190712_1616.py +++ b/sounds/migrations/0034_make_latest_index_20190712_1616.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-07-12 16:16 -from __future__ import unicode_literals from django.db import migrations diff --git a/sounds/migrations/0035_auto_20190724_1509.py b/sounds/migrations/0035_auto_20190724_1509.py index 1c89ee808e..cf297f2932 100644 --- a/sounds/migrations/0035_auto_20190724_1509.py +++ b/sounds/migrations/0035_auto_20190724_1509.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-07-24 15:09 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/sounds/migrations/0036_sound_uploaded_with_bulk_upload_progress.py b/sounds/migrations/0036_sound_uploaded_with_bulk_upload_progress.py index 8b24f2448a..ddc134f4f8 100644 --- a/sounds/migrations/0036_sound_uploaded_with_bulk_upload_progress.py +++ b/sounds/migrations/0036_sound_uploaded_with_bulk_upload_progress.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2020-04-29 15:52 -from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion diff --git a/sounds/migrations/0037_license_short_summary.py b/sounds/migrations/0037_license_short_summary.py index 79becad118..ba48e04372 100644 --- a/sounds/migrations/0037_license_short_summary.py +++ b/sounds/migrations/0037_license_short_summary.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.29 on 2021-02-05 10:15 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/sounds/migrations/0038_auto_20210412_1539.py b/sounds/migrations/0038_auto_20210412_1539.py index f61e7f9e11..664a6f544e 100644 --- a/sounds/migrations/0038_auto_20210412_1539.py +++ b/sounds/migrations/0038_auto_20210412_1539.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.29 on 2021-04-12 15:39 -from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models diff --git a/sounds/migrations/0039_auto_20210607_1404.py b/sounds/migrations/0039_auto_20210607_1404.py index 1acf598e95..ebb41016f7 100644 --- a/sounds/migrations/0039_auto_20210607_1404.py +++ b/sounds/migrations/0039_auto_20210607_1404.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.29 on 2021-06-07 14:04 -from __future__ import unicode_literals from django.db import migrations diff --git a/sounds/migrations/0040_auto_20220207_1627.py b/sounds/migrations/0040_auto_20220207_1627.py index 8528e3ce8d..c409301949 100644 --- a/sounds/migrations/0040_auto_20220207_1627.py +++ b/sounds/migrations/0040_auto_20220207_1627.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.29 on 2022-02-07 16:27 -from __future__ import unicode_literals from django.db import migrations, models @@ -43,6 +41,6 @@ class Migration(migrations.Migration): ), migrations.AlterUniqueTogether( name='soundanalysis', - unique_together=set([('sound', 'analyzer')]), + unique_together={('sound', 'analyzer')}, ), ] diff --git a/sounds/migrations/0041_soundanalysis_analysis_time.py b/sounds/migrations/0041_soundanalysis_analysis_time.py index 86d4456654..fafbb3bdcf 100644 --- a/sounds/migrations/0041_soundanalysis_analysis_time.py +++ b/sounds/migrations/0041_soundanalysis_analysis_time.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.29 on 2022-02-08 12:32 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/sounds/migrations/0042_auto_20220209_1027.py b/sounds/migrations/0042_auto_20220209_1027.py index f742971467..2f9e9e3d20 100644 --- a/sounds/migrations/0042_auto_20220209_1027.py +++ b/sounds/migrations/0042_auto_20220209_1027.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.29 on 2022-02-09 10:27 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/sounds/migrations/0043_auto_20220209_1027.py b/sounds/migrations/0043_auto_20220209_1027.py index e0fb51efc7..28b1451f55 100644 --- a/sounds/migrations/0043_auto_20220209_1027.py +++ b/sounds/migrations/0043_auto_20220209_1027.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.29 on 2022-02-09 10:27 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/sounds/migrations/0044_auto_20220209_1136.py b/sounds/migrations/0044_auto_20220209_1136.py index aab8c3a666..c5b112f6d0 100644 --- a/sounds/migrations/0044_auto_20220209_1136.py +++ b/sounds/migrations/0044_auto_20220209_1136.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.29 on 2022-02-09 11:36 -from __future__ import unicode_literals from django.db import models, migrations @@ -17,7 +15,7 @@ def update_existing_ac_analysis_objects(apps, schema_editor): if sa.analysis_data: updated_analysis_data = {} for key, value in sa.analysis_data.items(): - updated_analysis_data['ac_{0}'.format(key)] = value + updated_analysis_data['ac_{}'.format(key)] = value sa.analysis_data = updated_analysis_data sa.save() diff --git a/sounds/migrations/0045_add_new_licenses.py b/sounds/migrations/0045_add_new_licenses.py index f5ea13b59d..66165013b7 100644 --- a/sounds/migrations/0045_add_new_licenses.py +++ b/sounds/migrations/0045_add_new_licenses.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.29 on 2022-03-18 11:39 -from __future__ import unicode_literals from django.db import migrations diff --git a/sounds/migrations/0046_auto_20230201_1102.py b/sounds/migrations/0046_auto_20230201_1102.py index 8521f7da0e..13ff50ece8 100644 --- a/sounds/migrations/0046_auto_20230201_1102.py +++ b/sounds/migrations/0046_auto_20230201_1102.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.29 on 2023-02-01 11:02 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/sounds/models.py b/sounds/models.py index c71cd911ce..e805aec90d 100644 --- a/sounds/models.py +++ b/sounds/models.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - # # Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA # @@ -20,12 +18,9 @@ # See AUTHORS file. # -from __future__ import division from future import standard_library standard_library.install_aliases() from future.utils import python_2_unicode_compatible -from builtins import str -from builtins import object from past.utils import old_div import datetime import glob @@ -295,7 +290,7 @@ def has_line_validation_errors(self): return len(self.validation_output['lines_with_errors']) > 0 return False - class Meta(object): + class Meta: permissions = ( ("can_describe_in_bulk", "Can use the Bulk Describe feature."), ) @@ -387,7 +382,7 @@ def get_analyzers_data_left_join_sql(self): def get_analysis_state_essentia_exists_sql(self): """Returns the SQL bits to add analysis_state_essentia_exists to the returned data indicating if thers is a SoundAnalysis objects existing for th given sound_id for the essentia analyzer and with status OK""" - return " exists(select 1 from sounds_soundanalysis where sounds_soundanalysis.sound_id = sound.id AND sounds_soundanalysis.analyzer = '{0}' AND sounds_soundanalysis.analysis_status = 'OK') as analysis_state_essentia_exists,".format(settings.FREESOUND_ESSENTIA_EXTRACTOR_NAME) + return " exists(select 1 from sounds_soundanalysis where sounds_soundanalysis.sound_id = sound.id AND sounds_soundanalysis.analyzer = '{}' AND sounds_soundanalysis.analysis_status = 'OK') as analysis_state_essentia_exists,".format(settings.FREESOUND_ESSENTIA_EXTRACTOR_NAME) def bulk_query_solr(self, sound_ids): """For each sound, get all fields needed to index the sound in Solr. Using this custom query to avoid the need @@ -548,7 +543,7 @@ def ordered_ids(self, sound_ids): class PublicSoundManager(models.Manager): """ a class which only returns public sounds """ def get_queryset(self): - return super(PublicSoundManager, self).get_queryset().filter(moderation_state="OK", processing_state="OK") + return super().get_queryset().filter(moderation_state="OK", processing_state="OK") class Sound(SocialModel): @@ -785,9 +780,9 @@ def get_large_thumbnail_abs_url(self): def get_channels_display(self): if self.channels == 1: - return u"Mono" + return "Mono" elif self.channels == 2: - return u"Stereo" + return "Stereo" else: return self.channels @@ -899,7 +894,7 @@ def get_sound_sources_as_set(self): """ Returns a set object with the integer sound IDs of the current sources of the sound """ - return set(source["id"] for source in self.sources.all().values("id")) + return {source["id"] for source in self.sources.all().values("id")} def set_sources(self, new_sources): """ @@ -1328,7 +1323,7 @@ class SoundOfTheDay(models.Model): objects = SoundOfTheDayManager() def __str__(self): - return u'Random sound of the day {0}'.format(self.date_display) + return 'Random sound of the day {}'.format(self.date_display) def notify_by_email(self): """Notify the user of this sound by email that their sound has been chosen @@ -1674,9 +1669,9 @@ class Flag(models.Model): created = models.DateTimeField(db_index=True, auto_now_add=True) def __unicode__(self): - return u"%s: %s" % (self.reason_type, self.reason[:100]) + return "%s: %s" % (self.reason_type, self.reason[:100]) - class Meta(object): + class Meta: ordering = ("-created",) @@ -1686,7 +1681,7 @@ class Download(models.Model): license = models.ForeignKey(License) created = models.DateTimeField(db_index=True, auto_now_add=True) - class Meta(object): + class Meta: ordering = ("-created",) indexes = [ models.Index(fields=['user', 'sound']), @@ -1758,7 +1753,7 @@ class SoundLicenseHistory(models.Model): sound = models.ForeignKey(Sound) created = models.DateTimeField(db_index=True, auto_now_add=True) - class Meta(object): + class Meta: ordering = ("-created",) @@ -1859,7 +1854,7 @@ def get_analysis_logs(self): file_contents = fid.read() fid.close() return file_contents - except IOError: + except OSError: return 'No logs available...' def re_run_analysis(self, verbose=True): @@ -1868,7 +1863,7 @@ def re_run_analysis(self, verbose=True): def __str__(self): return 'Analysis of sound {} with {}'.format(self.sound_id, self.analyzer) - class Meta(object): + class Meta: unique_together = (("sound", "analyzer")) # one sounds.SoundAnalysis object per sound<>analyzer combination def on_delete_sound_analysis(sender, instance, **kwargs): diff --git a/sounds/templatetags/display_pack.py b/sounds/templatetags/display_pack.py index 76f377544e..9bd0051823 100644 --- a/sounds/templatetags/display_pack.py +++ b/sounds/templatetags/display_pack.py @@ -18,7 +18,6 @@ # See AUTHORS file. # -from __future__ import absolute_import from django import template diff --git a/sounds/templatetags/display_remix.py b/sounds/templatetags/display_remix.py index 0e9ba8dc58..cdc730837c 100644 --- a/sounds/templatetags/display_remix.py +++ b/sounds/templatetags/display_remix.py @@ -18,9 +18,7 @@ # See AUTHORS file. # -from __future__ import absolute_import, division #avoid namespace clash with 'tags' templatetag -from builtins import str from django import template import json diff --git a/sounds/templatetags/display_sound.py b/sounds/templatetags/display_sound.py index 9ab02221bb..af4873df3d 100644 --- a/sounds/templatetags/display_sound.py +++ b/sounds/templatetags/display_sound.py @@ -18,7 +18,6 @@ # See AUTHORS file. # -from __future__ import absolute_import from django import template from django.conf import settings diff --git a/sounds/templatetags/sound_signature.py b/sounds/templatetags/sound_signature.py index 8014ef1252..7ce8206850 100644 --- a/sounds/templatetags/sound_signature.py +++ b/sounds/templatetags/sound_signature.py @@ -1,6 +1,5 @@ from future import standard_library standard_library.install_aliases() -from builtins import str import urllib.parse from django.urls import reverse from django.contrib.sites.models import Site diff --git a/sounds/tests/test_manager.py b/sounds/tests/test_manager.py index 4c8c900b12..d1e667d952 100644 --- a/sounds/tests/test_manager.py +++ b/sounds/tests/test_manager.py @@ -18,7 +18,6 @@ # See AUTHORS file. # -import six from django.conf import settings from django.test import TestCase @@ -70,7 +69,7 @@ def test_bulk_query_id_field_contents(self): self.assertEqual(Sound.objects.get(id=sound.id).original_filename, sound.original_filename) self.assertEqual(Sound.objects.get(id=sound.id).pack_id, sound.pack_id) self.assertEqual(Sound.objects.get(id=sound.id).license_id, sound.license_id) - six.assertCountEqual(self, Sound.objects.get(id=sound.id).get_sound_tags(), sound.tag_array) + self.assertCountEqual(Sound.objects.get(id=sound.id).get_sound_tags(), sound.tag_array) def test_bulk_query_solr_num_queries(self): @@ -89,7 +88,7 @@ def test_bulk_query_solr_field_contents(self): self.assertEqual(Sound.objects.get(id=sound.id).md5, sound.md5) self.assertEqual(Sound.objects.get(id=sound.id).pack_id, sound.pack_id) self.assertEqual(Sound.objects.get(id=sound.id).license_id, sound.license_id) - six.assertCountEqual(self, Sound.objects.get(id=sound.id).get_sound_tags(), sound.tag_array) + self.assertCountEqual(Sound.objects.get(id=sound.id).get_sound_tags(), sound.tag_array) def test_ordered_ids(self): @@ -123,7 +122,7 @@ def test_bulk_sounds_for_user(self): for i, sound in enumerate(Sound.objects.bulk_sounds_for_user(user_id=self.user.id)): self.assertEqual(self.user.id, sound.user_id) user_sound_ids_bulk_query.append(sound.id) - six.assertCountEqual(self, user_sound_ids, user_sound_ids_bulk_query) + self.assertCountEqual(user_sound_ids, user_sound_ids_bulk_query) def test_bulk_sounds_for_pack(self): @@ -148,7 +147,7 @@ def test_bulk_sounds_for_pack(self): for i, sound in enumerate(Sound.objects.bulk_sounds_for_pack(pack_id=self.pack.id)): self.assertEqual(self.user.id, sound.user_id) pack_sound_ids_bulk_query.append(sound.id) - six.assertCountEqual(self, pack_sound_ids, pack_sound_ids_bulk_query) + self.assertCountEqual(pack_sound_ids, pack_sound_ids_bulk_query) class PublicSoundManagerTest(TestCase): diff --git a/sounds/tests/test_sound.py b/sounds/tests/test_sound.py index ed4cef645f..c8e49a3d5e 100644 --- a/sounds/tests/test_sound.py +++ b/sounds/tests/test_sound.py @@ -18,17 +18,13 @@ # See AUTHORS file. # -from __future__ import print_function -from __future__ import division -from builtins import str from past.utils import old_div import json import os import time from unittest import mock -import six from bs4 import BeautifulSoup from django.conf import settings from django.contrib.auth.models import User @@ -70,7 +66,7 @@ def test_email_notificaiton_on_send_email(self): sound = Sound.objects.get(id=19) commenting_user = User.objects.get(id=2) self.client.force_login(commenting_user) - self.client.post(reverse('sound', args=[sound.user.username, sound.id]), {'comment': u'Test comment'}) + self.client.post(reverse('sound', args=[sound.user.username, sound.id]), {'comment': 'Test comment'}) # Check email was sent notifying about comment self.assertEqual(len(mail.outbox), 1) @@ -84,7 +80,7 @@ def test_email_notificaiton_on_send_email(self): accounts.models.UserEmailSetting.objects.create(user=sound.user, email_type=email_pref) # Make the comment again and assert no new email has been sent - self.client.post(reverse('sound', args=[sound.user.username, sound.id]), {'comment': u'Test comment'}) + self.client.post(reverse('sound', args=[sound.user.username, sound.id]), {'comment': 'Test comment'}) self.assertEqual(len(mail.outbox), 1) def test_unsecure_content(self): @@ -178,7 +174,7 @@ def test_change_sound_owner(self, delete_sounds_from_search_engine): # Delete original user and perform further checks userA.profile.delete_user(delete_user_object_from_db=True) sound = Sound.objects.get(id=target_sound_id) - six.assertCountEqual(self, [ti.id for ti in sound.tags.all()], target_sound_tags) + self.assertCountEqual([ti.id for ti in sound.tags.all()], target_sound_tags) delete_sounds_from_search_engine.assert_has_calls([mock.call([i]) for i in remaining_sound_ids], any_order=True) @@ -291,9 +287,9 @@ def test_edit_sound(self): self.client.force_login(user) resp = self.client.post(reverse('sound-edit', args=[sound.user.username, sound.id]), { - 'submit': [u'submit'], - 'pack-new_pack': [u'new pack name'], - 'pack-pack': [u''], + 'submit': ['submit'], + 'pack-new_pack': ['new pack name'], + 'pack-pack': [''], }) self.assertRedirects(resp, reverse('sound', args=[sound.user.username, sound.id])) self.assertEqual(Pack.objects.get(id=pack.id).num_sounds, 0) # Sound changed from pack @@ -314,10 +310,10 @@ def test_edit_pack(self): sound_ids_pack2.append(sound_ids_pack1.pop()) self.client.force_login(user) resp = self.client.post(reverse('pack-edit', args=[pack2.user.username, pack2.id]), { - 'submit': [u'submit'], - 'pack_sounds': u','.join([str(sid) for sid in sound_ids_pack2]), - 'name': [u'Test pack 1 (edited)'], - 'description': [u'A new description'] + 'submit': ['submit'], + 'pack_sounds': ','.join([str(sid) for sid in sound_ids_pack2]), + 'name': ['Test pack 1 (edited)'], + 'description': ['A new description'] }) self.assertRedirects(resp, reverse('pack', args=[pack2.user.username, pack2.id])) self.assertEqual(Pack.objects.get(id=pack1.id).num_sounds, 1) @@ -329,11 +325,11 @@ def test_edit_pack(self): sound.change_processing_state("OK") sound.change_moderation_state("OK") resp = self.client.post(reverse('pack-edit', args=[pack2.user.username, pack2.id]), { - 'submit': [u'submit'], + 'submit': ['submit'], 'pack_sounds': - u','.join([str(snd.id) for snd in Pack.objects.get(id=pack2.id).sounds.all()] + [str(sound.id)]), - 'name': [u'Test pack 1 (edited again)'], - 'description': [u'A new description'] + ','.join([str(snd.id) for snd in Pack.objects.get(id=pack2.id).sounds.all()] + [str(sound.id)]), + 'name': ['Test pack 1 (edited again)'], + 'description': ['A new description'] }) self.assertRedirects(resp, reverse('pack', args=[pack2.user.username, pack2.id])) self.assertEqual(Pack.objects.get(id=pack1.id).num_sounds, 1) @@ -701,12 +697,12 @@ def test_update_description(self): self._assertCachePresent(cache_keys) # Edit sound - new_description = u'New description' - new_name = u'New name' + new_description = 'New description' + new_name = 'New name' resp = self.client.post(self._get_sound_url('sound-edit'), { 'description-description': new_description, 'description-name': new_name, - 'description-tags': u'tag1 tag2 tag3' + 'description-tags': 'tag1 tag2 tag3' }) self.assertEqual(resp.status_code, 302) @@ -733,13 +729,13 @@ def test_update_description_bw(self): self._assertCachePresent(cache_keys) # Edit sound - new_description = u'New description' - new_name = u'New name' + new_description = 'New description' + new_name = 'New name' resp = self.client.post(self._get_sound_url('sound-edit'), { '0-description': new_description, '0-name': new_name, - '0-tags': u'tag1 tag2 tag3', - '0-license': [u'3'], + '0-tags': 'tag1 tag2 tag3', + '0-license': ['3'], }) self.assertEqual(resp.status_code, 302) @@ -769,7 +765,7 @@ def test_add_remove_comment(self): # Add comment resp = self.client.post(self._get_sound_url('sound'), { - 'comment': u'Test comment' + 'comment': 'Test comment' }, follow=True) # we are testing sound-display, rendering sound view is ok delete_url = self._get_delete_comment_url(resp.content) self._assertCacheAbsent(cache_keys) @@ -1205,10 +1201,10 @@ def setUp(self): def test_update_description_bw(self): test_using_bw_ui(self) self.client.force_login(self.user) - new_description = u'New description' - new_name = u'New name' + new_description = 'New description' + new_name = 'New name' new_tags = ['tag1', 'tag2', 'tag3'] - new_pack_name = u'Name of a new pack' + new_pack_name = 'Name of a new pack' new_sound_sources = Sound.objects.exclude(id=self.sound.id) geotag_lat = 46.31658418182218 resp = self.client.post(reverse('sound-edit', args=[self.sound.user.username, self.sound.id]), { @@ -1216,7 +1212,7 @@ def test_update_description_bw(self): '0-name': new_name, '0-tags': ' '.join(new_tags), '0-license': '3', - '0-sources': ','.join([u'{}'.format(s.id) for s in new_sound_sources]), + '0-sources': ','.join(['{}'.format(s.id) for s in new_sound_sources]), '0-pack': '', '0-new_pack': new_pack_name, '0-lat': '{}'.format(geotag_lat), diff --git a/sounds/views.py b/sounds/views.py index d5baf52f86..baa6efff8a 100644 --- a/sounds/views.py +++ b/sounds/views.py @@ -1,4 +1,3 @@ -from __future__ import division # # Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA # @@ -19,8 +18,6 @@ # See AUTHORS file. # -from builtins import map -from builtins import str from past.utils import old_div import datetime import json @@ -205,7 +202,7 @@ def front_page(request): top_donor_user_id = cache.get("top_donor_user_id", None) top_donor_donation_amount = cache.get("top_donor_donation_amount", None) if popular_searches is not None: - popular_searches = [(query_terms, '{0}?q={1}'.format(reverse('sounds-search'), query_terms)) + popular_searches = [(query_terms, '{}?q={}'.format(reverse('sounds-search'), query_terms)) for query_terms in popular_searches] current_forum_threads = get_hot_threads(n=10) @@ -627,11 +624,11 @@ def create_sounds(request, forms): sounds_to_process.append(sound) if user.profile.is_whitelisted: messages.add_message(request, messages.INFO, - u'File {} has been described and has been added to freesound.'\ + 'File {} has been described and has been added to freesound.'\ .format(sound.get_absolute_url(), sound.original_filename)) else: messages.add_message(request, messages.INFO, - u'File {} has been described and is now awaiting processing and moderation.'\ + 'File {} has been described and is now awaiting processing and moderation.'\ .format(sound.get_absolute_url(), sound.original_filename)) invalidate_user_template_caches(request.user.id) for moderator in Group.objects.get(name='moderators').user_set.all(): @@ -1039,7 +1036,7 @@ def pack(request, username, pack_id): @redirect_if_old_username_or_404 def packs_for_user(request, username): if using_beastwhoosh(request): - return HttpResponseRedirect(u'{0}?f=username:%22{1}%22&s=Date+added+(newest+first)&g=1&only_p=1'.format(reverse('sounds-search'), username)) + return HttpResponseRedirect('{}?f=username:%22{}%22&s=Date+added+(newest+first)&g=1&only_p=1'.format(reverse('sounds-search'), username)) user = request.parameter_user order = request.GET.get("order", "name") @@ -1057,7 +1054,7 @@ def packs_for_user(request, username): @redirect_if_old_username_or_404 def for_user(request, username): if using_beastwhoosh(request): - return HttpResponseRedirect(u'{0}?f=username:%22{1}%22&s=Date+added+(newest+first)&g=1'.format(reverse('sounds-search'), username)) + return HttpResponseRedirect('{}?f=username:%22{}%22&s=Date+added+(newest+first)&g=1'.format(reverse('sounds-search'), username)) sound_user = request.parameter_user paginator = paginate(request, Sound.public.only('id').filter(user=sound_user), settings.SOUNDS_PER_PAGE) diff --git a/support/admin.py b/support/admin.py index 7c68785e9d..e69de29bb2 100644 --- a/support/admin.py +++ b/support/admin.py @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- \ No newline at end of file diff --git a/support/models.py b/support/models.py index 7c68785e9d..e69de29bb2 100644 --- a/support/models.py +++ b/support/models.py @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- \ No newline at end of file diff --git a/support/tests.py b/support/tests.py index 4c5b311204..1f402a9d49 100644 --- a/support/tests.py +++ b/support/tests.py @@ -35,12 +35,12 @@ def test_send_support_request_email(self): # try with existing email address request_email = 'test.user+1@gmail.com' send_email_to_support(request_email, subject, message) - self.assert_(True) # This call is not really needed, but makes sense to me + self.assertTrue(True) # This call is not really needed, but makes sense to me # try with non-existing email address request_email = 'test.user+1234678235@gmail.com' send_email_to_support(request_email, subject, message) - self.assert_(True) # This call is not really needed, but makes sense to me + self.assertTrue(True) # This call is not really needed, but makes sense to me def test_create_zendesk_ticket(self): subject = 'test subject' diff --git a/support/views.py b/support/views.py index 238cdf966d..0537e06273 100644 --- a/support/views.py +++ b/support/views.py @@ -18,7 +18,6 @@ # See AUTHORS file. # -from builtins import str import logging from django.conf import settings diff --git a/tags/admin.py b/tags/admin.py index 20c4e32956..200f8d6272 100644 --- a/tags/admin.py +++ b/tags/admin.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - # # Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA # diff --git a/tags/migrations/0001_initial.py b/tags/migrations/0001_initial.py index 368176d30c..5ffdc34f23 100644 --- a/tags/migrations/0001_initial.py +++ b/tags/migrations/0001_initial.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.9.5 on 2016-04-15 11:33 -from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models @@ -55,6 +53,6 @@ class Migration(migrations.Migration): ), migrations.AlterUniqueTogether( name='taggeditem', - unique_together=set([('tag', 'content_type', 'object_id')]), + unique_together={('tag', 'content_type', 'object_id')}, ), ] diff --git a/tags/models.py b/tags/models.py index 5f9cf8a357..e84dbe53e0 100644 --- a/tags/models.py +++ b/tags/models.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - # # Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA # @@ -20,7 +18,6 @@ # See AUTHORS file. # -from builtins import object from django.contrib.auth.models import User from django.contrib.contenttypes import fields from django.contrib.contenttypes.models import ContentType @@ -37,7 +34,7 @@ def __str__(self): def get_browse_tag_url(self): return reverse('tags', self.name) - class Meta(object): + class Meta: ordering = ("name",) @@ -54,12 +51,12 @@ class TaggedItem(models.Model): created = models.DateTimeField(db_index=True, auto_now_add=True) def __str__(self): - return u"%s tagged %s - %s: %s" % (self.user, self.content_type, self.content_type, self.tag) + return "%s tagged %s - %s: %s" % (self.user, self.content_type, self.content_type, self.tag) def get_absolute_url(self): return reverse('tag', args=[smart_text(self.tag.id)]) - class Meta(object): + class Meta: ordering = ("-created",) unique_together = (('tag', 'content_type', 'object_id'),) diff --git a/tags/tests.py b/tags/tests.py index 9310005736..8f37f5c989 100644 --- a/tags/tests.py +++ b/tags/tests.py @@ -18,7 +18,6 @@ # See AUTHORS file. # -from builtins import str from django.test import TestCase from django.urls import reverse diff --git a/tickets/admin.py b/tickets/admin.py index a077451175..dca5f75541 100644 --- a/tickets/admin.py +++ b/tickets/admin.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - # # Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA # @@ -20,7 +18,6 @@ # See AUTHORS file. # -from __future__ import absolute_import from django.contrib import admin from .models import Queue, Ticket diff --git a/tickets/forms.py b/tickets/forms.py index 82f3941cdc..e6f12369cf 100644 --- a/tickets/forms.py +++ b/tickets/forms.py @@ -38,7 +38,7 @@ class UserContactForm(UserMessageForm): title = HtmlCleaningCharField() def __init__(self, *args, **kwargs): - super(UserContactForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.fields.keyOrder = ['title', 'message'] @@ -52,7 +52,7 @@ class AnonymousContactForm(AnonymousMessageForm): email = forms.EmailField() def __init__(self, *args, **kwargs): - super(AnonymousContactForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.fields.keyOrder = ['email', 'title', 'message'] diff --git a/tickets/migrations/0001_initial.py b/tickets/migrations/0001_initial.py index 58d5cb2aeb..31526cf494 100644 --- a/tickets/migrations/0001_initial.py +++ b/tickets/migrations/0001_initial.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.9.5 on 2016-04-15 11:33 -from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models diff --git a/tickets/migrations/0002_auto_20160505_1202.py b/tickets/migrations/0002_auto_20160505_1202.py index b3abde94a7..4ec323850c 100644 --- a/tickets/migrations/0002_auto_20160505_1202.py +++ b/tickets/migrations/0002_auto_20160505_1202.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.9.5 on 2016-05-05 12:02 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/tickets/migrations/0003_ticket_sound.py b/tickets/migrations/0003_ticket_sound.py index 446a5bd742..27426e1e95 100644 --- a/tickets/migrations/0003_ticket_sound.py +++ b/tickets/migrations/0003_ticket_sound.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.9.5 on 2016-06-08 13:07 -from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion diff --git a/tickets/migrations/0004_copy.py b/tickets/migrations/0004_copy.py index 8b000056eb..5e58f65dfd 100644 --- a/tickets/migrations/0004_copy.py +++ b/tickets/migrations/0004_copy.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - from tickets import TICKET_STATUS_CLOSED from django.db import models, migrations from django.contrib.contenttypes.models import ContentType diff --git a/tickets/migrations/0005_auto_20160608_1546.py b/tickets/migrations/0005_auto_20160608_1546.py index 4bd506e68b..41e080d730 100644 --- a/tickets/migrations/0005_auto_20160608_1546.py +++ b/tickets/migrations/0005_auto_20160608_1546.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.9.5 on 2016-06-08 15:46 -from __future__ import unicode_literals from django.db import migrations diff --git a/tickets/migrations/0006_remove_ticket_source.py b/tickets/migrations/0006_remove_ticket_source.py index 4dada83d97..495583b6f3 100644 --- a/tickets/migrations/0006_remove_ticket_source.py +++ b/tickets/migrations/0006_remove_ticket_source.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.9.5 on 2016-07-13 10:36 -from __future__ import unicode_literals from django.db import migrations diff --git a/tickets/migrations/0007_auto_20170626_1755.py b/tickets/migrations/0007_auto_20170626_1755.py index 434ed32290..f4bc56d77a 100644 --- a/tickets/migrations/0007_auto_20170626_1755.py +++ b/tickets/migrations/0007_auto_20170626_1755.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2017-06-26 17:55 -from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models diff --git a/tickets/migrations/0008_copy_message_to_ticket.py b/tickets/migrations/0008_copy_message_to_ticket.py index 740221b273..d811ca95ac 100644 --- a/tickets/migrations/0008_copy_message_to_ticket.py +++ b/tickets/migrations/0008_copy_message_to_ticket.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.db import models, migrations from django.contrib.contenttypes.models import ContentType diff --git a/tickets/migrations/0009_auto_20190528_1554.py b/tickets/migrations/0009_auto_20190528_1554.py index 975e6f3fc1..fef8635142 100644 --- a/tickets/migrations/0009_auto_20190528_1554.py +++ b/tickets/migrations/0009_auto_20190528_1554.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-05-28 15:54 -from __future__ import unicode_literals from django.db import migrations diff --git a/tickets/models.py b/tickets/models.py index e116bca130..794d147acc 100644 --- a/tickets/models.py +++ b/tickets/models.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - # # Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA # @@ -20,8 +18,6 @@ # See AUTHORS file. # -from builtins import str -from builtins import object from django.conf import settings from django.contrib.auth.models import User, Group from django.contrib.contenttypes.models import ContentType @@ -102,9 +98,9 @@ def get_absolute_url(self): return reverse('ticket', args=[smart_text(self.key)]) def __str__(self): - return u"pk %s, key %s" % (self.id, self.key) + return "pk %s, key %s" % (self.id, self.key) - class Meta(object): + class Meta: ordering = ("-created",) permissions = ( ("can_moderate", "Can moderate stuff."), @@ -119,10 +115,10 @@ class TicketComment(models.Model): moderator_only = models.BooleanField(default=False) def __str__(self): - return u"<# Message - ticket_id: %s, ticket_key: %s>" % \ + return "<# Message - ticket_id: %s, ticket_key: %s>" % \ (self.ticket.id, self.ticket.key) - class Meta(object): + class Meta: ordering = ("-created",) diff --git a/tickets/tests.py b/tickets/tests.py index 59d8baad89..f2a808b05f 100644 --- a/tickets/tests.py +++ b/tickets/tests.py @@ -18,7 +18,6 @@ # See AUTHORS file. # -from __future__ import absolute_import from future import standard_library standard_library.install_aliases() @@ -161,12 +160,12 @@ def setUp(self): def _perform_action(self, action): return self.client.post(reverse('tickets-moderation-assigned', args=[self.test_moderator.id]), { - 'action': action, 'message': u'', 'ticket': self.ticket.id, + 'action': action, 'message': '', 'ticket': self.ticket.id, 'is_explicit': IS_EXPLICIT_KEEP_USER_PREFERENCE_KEY}) @mock.patch('sounds.models.delete_sounds_from_search_engine') def test_delete_ticket_from_queue(self, delete_sound_solr): - resp = self._perform_action(u'Delete') + resp = self._perform_action('Delete') self.assertEqual(resp.status_code, 200) delete_sound_solr.assert_called_once_with([self.sound.id]) @@ -177,7 +176,7 @@ def test_delete_ticket_from_queue(self, delete_sound_solr): @mock.patch('general.tasks.whitelist_user.delay') def test_whitelist_from_queue(self, whitelist_task): - self._perform_action(u'Whitelist') + self._perform_action('Whitelist') whitelist_task.assert_called_once_with(ticket_ids=[self.ticket.id]) def _assert_ticket_and_sound_fields(self, status, assignee, moderation_state): @@ -191,17 +190,17 @@ def _assert_ticket_and_sound_fields(self, status, assignee, moderation_state): self.assertEqual(self.ticket.assignee, assignee) def test_approve_ticket_from_queue(self): - resp = self._perform_action(u'Approve') + resp = self._perform_action('Approve') self.assertEqual(resp.status_code, 200) self._assert_ticket_and_sound_fields(TICKET_STATUS_CLOSED, self.test_moderator, 'OK') def test_return_ticket_from_queue(self): - resp = self._perform_action(u'Return') + resp = self._perform_action('Return') self.assertEqual(resp.status_code, 200) self._assert_ticket_and_sound_fields(TICKET_STATUS_NEW, None, 'PE') def test_defer_ticket_from_queue(self): - resp = self._perform_action(u'Defer') + resp = self._perform_action('Defer') self.assertEqual(resp.status_code, 200) self._assert_ticket_and_sound_fields(TICKET_STATUS_DEFERRED, self.test_moderator, 'PE') @@ -233,7 +232,7 @@ def setUp(self): def _perform_action(self, action, is_explicit_flag_key): return self.client.post(reverse('tickets-moderation-assigned', args=[self.test_moderator.id]), { - 'action': action, 'message': u'', 'ticket': self.ticket.id, 'is_explicit': is_explicit_flag_key}) + 'action': action, 'message': '', 'ticket': self.ticket.id, 'is_explicit': is_explicit_flag_key}) def test_keep_is_explicit_preference_for_explicit_sound(self): """Test that when approving a sound marked as 'is_explicit' it continues to be marked as such the moderator @@ -241,7 +240,7 @@ def test_keep_is_explicit_preference_for_explicit_sound(self): """ self.ticket.sound.is_explicit = True self.ticket.sound.save() - self._perform_action(u'Approve', IS_EXPLICIT_KEEP_USER_PREFERENCE_KEY) + self._perform_action('Approve', IS_EXPLICIT_KEEP_USER_PREFERENCE_KEY) self.ticket.sound.refresh_from_db() self.assertEqual(self.ticket.sound.is_explicit, True) @@ -251,7 +250,7 @@ def test_keep_is_explicit_preference_for_non_explicit_sound(self): """ self.ticket.sound.is_explicit = False self.ticket.sound.save() - self._perform_action(u'Approve', IS_EXPLICIT_KEEP_USER_PREFERENCE_KEY) + self._perform_action('Approve', IS_EXPLICIT_KEEP_USER_PREFERENCE_KEY) self.ticket.sound.refresh_from_db() self.assertEqual(self.ticket.sound.is_explicit, False) @@ -261,7 +260,7 @@ def test_add_is_explicit_flag_for_explicit_sound(self): """ self.ticket.sound.is_explicit = True self.ticket.sound.save() - self._perform_action(u'Approve', IS_EXPLICIT_ADD_FLAG_KEY) + self._perform_action('Approve', IS_EXPLICIT_ADD_FLAG_KEY) self.ticket.sound.refresh_from_db() self.assertTrue(self.ticket.sound.is_explicit) @@ -271,7 +270,7 @@ def test_add_is_explicit_flag_for_non_explicit_sound(self): """ self.ticket.sound.is_explicit = False self.ticket.sound.save() - self._perform_action(u'Approve', IS_EXPLICIT_ADD_FLAG_KEY) + self._perform_action('Approve', IS_EXPLICIT_ADD_FLAG_KEY) self.ticket.sound.refresh_from_db() self.assertTrue(self.ticket.sound.is_explicit) @@ -281,7 +280,7 @@ def test_remove_is_explicit_flag_for_non_explicit_sound(self): """ self.ticket.sound.is_explicit = False self.ticket.sound.save() - self._perform_action(u'Approve', IS_EXPLICIT_REMOVE_FLAG_KEY) + self._perform_action('Approve', IS_EXPLICIT_REMOVE_FLAG_KEY) self.ticket.sound.refresh_from_db() self.assertFalse(self.ticket.sound.is_explicit) @@ -291,6 +290,6 @@ def test_remove_is_explicit_flag_for_explicit_sound(self): """ self.ticket.sound.is_explicit = True self.ticket.sound.save() - self._perform_action(u'Approve', IS_EXPLICIT_REMOVE_FLAG_KEY) + self._perform_action('Approve', IS_EXPLICIT_REMOVE_FLAG_KEY) self.ticket.sound.refresh_from_db() self.assertFalse(self.ticket.sound.is_explicit) diff --git a/tickets/urls.py b/tickets/urls.py index 356bbf6739..a44ebbaa60 100644 --- a/tickets/urls.py +++ b/tickets/urls.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - # # Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA # diff --git a/tickets/views.py b/tickets/views.py index 9d7c91087c..2bdf474558 100644 --- a/tickets/views.py +++ b/tickets/views.py @@ -18,7 +18,6 @@ # See AUTHORS file. # -from __future__ import absolute_import import datetime import json diff --git a/utils/audioprocessing/color_schemes.py b/utils/audioprocessing/color_schemes.py index 8914fa5ae7..d83b9e8283 100644 --- a/utils/audioprocessing/color_schemes.py +++ b/utils/audioprocessing/color_schemes.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import map -from builtins import range from past.utils import old_div from PIL import ImageColor from functools import partial diff --git a/utils/audioprocessing/convert_to_mp3.py b/utils/audioprocessing/convert_to_mp3.py index 58e95eaf40..e5e693ee40 100755 --- a/utils/audioprocessing/convert_to_mp3.py +++ b/utils/audioprocessing/convert_to_mp3.py @@ -20,7 +20,6 @@ # See AUTHORS file. # -from __future__ import absolute_import import sys from .processing import convert_to_mp3 diff --git a/utils/audioprocessing/convert_to_wav.py b/utils/audioprocessing/convert_to_wav.py index 10563e8c7e..5e1b7aff2e 100644 --- a/utils/audioprocessing/convert_to_wav.py +++ b/utils/audioprocessing/convert_to_wav.py @@ -20,8 +20,6 @@ # See AUTHORS file. # -from __future__ import print_function -from __future__ import absolute_import import sys from .processing import convert_to_wav, audio_info, AudioProcessingException diff --git a/utils/audioprocessing/freesound_audio_processing.py b/utils/audioprocessing/freesound_audio_processing.py index d06f708a95..bf6325ea4f 100644 --- a/utils/audioprocessing/freesound_audio_processing.py +++ b/utils/audioprocessing/freesound_audio_processing.py @@ -18,12 +18,8 @@ # See AUTHORS file. # -from __future__ import absolute_import -from __future__ import division -from builtins import str from past.utils import old_div -from builtins import object import json import os import signal @@ -90,7 +86,7 @@ def check_if_free_space(directory=settings.PROCESSING_TEMP_DIR, "aborting task as there might not be enough space for temp files") -class FreesoundAudioProcessorBase(object): +class FreesoundAudioProcessorBase: """ Base class to be used for Freesound processing and analysis code. It implements methods common to both use cases. @@ -185,7 +181,7 @@ def convert_to_pcm(self, sound_path, tmp_directory, force_use_ffmpeg=False, mono class FreesoundAudioProcessor(FreesoundAudioProcessorBase): def set_failure(self, message, error=None): - super(FreesoundAudioProcessor, self).set_failure(message, error) + super().set_failure(message, error) self.sound.set_processing_ongoing_state("FI") self.sound.change_processing_state("FA", processing_log=self.work_log) diff --git a/utils/audioprocessing/processing.py b/utils/audioprocessing/processing.py index 0c95f41b22..c1adf9bee0 100644 --- a/utils/audioprocessing/processing.py +++ b/utils/audioprocessing/processing.py @@ -20,14 +20,7 @@ # See AUTHORS file. # -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division - -from builtins import str -from builtins import range -from builtins import object -from builtins import bytes + from past.utils import old_div import math import os @@ -46,7 +39,7 @@ class AudioProcessingException(Exception): pass -class TestAudioFile(object): +class TestAudioFile: """A class that mimics pysndfile.PySndfile but generates noise instead of reading a wave file. Additionally it can be told to have a "broken" header and thus crashing in the middle of the file. Also useful for testing ultra-short files of 20 samples.""" @@ -99,7 +92,7 @@ def get_max_level(filename): return max_value -class AudioProcessor(object): +class AudioProcessor: """ The audio processor processes chunks of audio an calculates the spectrac centroid and the peak samples in that chunk of audio. @@ -281,7 +274,7 @@ def interpolate_colors(colors, flat=False, num_colors=256): return palette -class WaveformImage(object): +class WaveformImage: """ Given peaks and spectral centroids from the AudioProcessor, this class will construct a wavefile image which can be saved as PNG. @@ -361,7 +354,7 @@ def save(self, filename): self.image.save(filename) -class SpectrogramImage(object): +class SpectrogramImage: """ Given spectra from the AudioProcessor, this class will construct a wavefile image which can be saved as PNG. diff --git a/utils/audioprocessing/wav2png.py b/utils/audioprocessing/wav2png.py index c072705218..55e6d78f40 100755 --- a/utils/audioprocessing/wav2png.py +++ b/utils/audioprocessing/wav2png.py @@ -20,10 +20,7 @@ # See AUTHORS file. # -from __future__ import print_function, absolute_import -from __future__ import division -from builtins import str from past.utils import old_div import argparse diff --git a/utils/aws.py b/utils/aws.py index 43bab70e2d..1793ca6e2f 100644 --- a/utils/aws.py +++ b/utils/aws.py @@ -18,7 +18,6 @@ # See AUTHORS file. # -from builtins import object from django.conf import settings from boto3 import client @@ -48,7 +47,7 @@ def init_client(service): aws_secret_access_key=settings.AWS_SQS_SECRET_ACCESS_KEY) -class EmailStats(object): +class EmailStats: total = 0 bounces = 0 complaints = 0 diff --git a/utils/dbtime.py b/utils/dbtime.py index ce8be2407e..89c9fef34b 100644 --- a/utils/dbtime.py +++ b/utils/dbtime.py @@ -20,14 +20,13 @@ from datetime import datetime -from builtins import object from django.conf import settings from django.core.cache import cache from sounds.models import Sound, Download -class DBTime(object): +class DBTime: last_time = None @staticmethod diff --git a/utils/downloads.py b/utils/downloads.py index a6ab48b24c..28f9061c99 100644 --- a/utils/downloads.py +++ b/utils/downloads.py @@ -1,4 +1,3 @@ - # # Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA # diff --git a/utils/encryption.py b/utils/encryption.py index dc13ac8713..2dc9144802 100644 --- a/utils/encryption.py +++ b/utils/encryption.py @@ -20,7 +20,6 @@ from future import standard_library standard_library.install_aliases() -from builtins import str import hashlib from django.core.signing import TimestampSigner diff --git a/utils/filesystem.py b/utils/filesystem.py index 6d327724ff..a40ef2f68f 100644 --- a/utils/filesystem.py +++ b/utils/filesystem.py @@ -18,17 +18,14 @@ # See AUTHORS file. # -from __future__ import print_function -from builtins import hex -from builtins import object import hashlib import os import shutil import zlib -class File(object): +class File: def __init__(self, id, name, full_path, is_dir): self.name = name diff --git a/utils/forms.py b/utils/forms.py index e52e7b384d..961986c240 100644 --- a/utils/forms.py +++ b/utils/forms.py @@ -36,7 +36,7 @@ class HtmlCleaningCharField(forms.CharField): """ A field that removes disallowed HTML tags as implemented in utils.text.clean_html and checks for too many upper chase characters""" def clean(self, value): - value = super(HtmlCleaningCharField, self).clean(value) + value = super().clean(value) if is_shouting(value): raise forms.ValidationError('Please moderate the amount of upper case characters in your post...') return clean_html(value) @@ -47,7 +47,7 @@ class TagField(forms.CharField): unique tag strings """ def __init__(self, **kwargs): - super(TagField, self).__init__(**kwargs) + super().__init__(**kwargs) self.validators.append( validators.MinLengthValidator(3, 'You should add at least 3 different tags. Tags must be separated by ' 'spaces')) @@ -55,7 +55,7 @@ def __init__(self, **kwargs): validators.MaxLengthValidator(30, 'There can be maximum 30 tags, please select the most relevant ones!')) def to_python(self, value): - value = super(TagField, self).to_python(value) + value = super().to_python(value) alphanum_only = re.compile(r"[^ a-zA-Z0-9-,]") if alphanum_only.search(value): raise ValidationError("Tags must contain only letters a-z, digits 0-9 and hyphen") diff --git a/utils/images.py b/utils/images.py index d11ee8dae1..cd9f5c5c0c 100644 --- a/utils/images.py +++ b/utils/images.py @@ -1,4 +1,3 @@ -from __future__ import division # # Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA # diff --git a/utils/locations.py b/utils/locations.py index d19143af48..29f545fbd8 100644 --- a/utils/locations.py +++ b/utils/locations.py @@ -18,9 +18,7 @@ # See AUTHORS file. # -from __future__ import print_function -from builtins import object def locations_decorator(cache=True): """wraps a locations function and adds two things: * caching for the calculation done inside the function if cache is true @@ -57,7 +55,7 @@ def pretty_print_locations(locations, indent=0): if __name__ == "__main__": - class X(object): + class X: @locations_decorator() def locations(self): return dict(a=5) diff --git a/utils/logging_filters.py b/utils/logging_filters.py index 436ee5115b..2229ec169f 100644 --- a/utils/logging_filters.py +++ b/utils/logging_filters.py @@ -18,7 +18,6 @@ # See AUTHORS file. # -from builtins import str import ipaddress import logging import json diff --git a/utils/mail.py b/utils/mail.py index c0ea8044ed..c60a960936 100644 --- a/utils/mail.py +++ b/utils/mail.py @@ -18,7 +18,6 @@ # See AUTHORS file. # -from builtins import str import logging import json @@ -105,9 +104,9 @@ def send_mail(subject, email_body, user_to=None, email_to=None, email_from=None, if settings.ALLOWED_EMAILS: # for testing purposes, so we don't accidentally send emails to users email_to = [(username, email) for username, email in email_to if email in settings.ALLOWED_EMAILS] - full_subject = u'{} {}'.format(settings.EMAIL_SUBJECT_PREFIX, subject) + full_subject = '{} {}'.format(settings.EMAIL_SUBJECT_PREFIX, subject) if extra_subject: - full_subject = u'{} - {}'.format(full_subject, extra_subject) + full_subject = '{} - {}'.format(full_subject, extra_subject) try: emails = tuple(((full_subject, email_body, email_from, [email]) diff --git a/utils/management_commands.py b/utils/management_commands.py index 5265090397..0167490fb5 100644 --- a/utils/management_commands.py +++ b/utils/management_commands.py @@ -60,7 +60,7 @@ def log_start(self, data=None): if data is None: data = {} data['command'] = self.command_name - commands_logger.info('Started management command ({0})'.format(json.dumps(data))) + commands_logger.info('Started management command ({})'.format(json.dumps(data))) def log_end(self, data=None): if data is None: @@ -68,4 +68,4 @@ def log_end(self, data=None): if self.start_time: data['work_time'] = round(time.time() - self.start_time) data['command'] = self.command_name or self.find_command_name() - commands_logger.info('Finished management command ({0})'.format(json.dumps(data))) + commands_logger.info('Finished management command ({})'.format(json.dumps(data))) diff --git a/utils/mirror_files.py b/utils/mirror_files.py index d746edebac..d7976e7a45 100644 --- a/utils/mirror_files.py +++ b/utils/mirror_files.py @@ -1,4 +1,3 @@ -from builtins import str from django.conf import settings import os import shutil @@ -29,7 +28,7 @@ def copy_files(source_destination_tuples): shutil.copy2(source_path, destination_path) if settings.LOG_START_AND_END_COPYING_FILES: web_logger.info('Finished copying file %s to %s' % (source_path, destination_path)) - except IOError as e: + except OSError as e: # File does not exist, no permissions, etc. web_logger.error('Failed copying %s (%s)' % (source_path, str(e))) diff --git a/utils/nginxsendfile.py b/utils/nginxsendfile.py index 73423d9d70..20a10ebe73 100644 --- a/utils/nginxsendfile.py +++ b/utils/nginxsendfile.py @@ -32,8 +32,8 @@ def prepare_sendfile_arguments_for_sound_download(sound): if settings.USE_PREVIEWS_WHEN_ORIGINAL_FILES_MISSING and not os.path.exists(sound_path): sound_path = sound.locations("preview.LQ.mp3.path") - sound_friendly_filename = '{0}.{1}'.format(sound_friendly_filename[:sound_friendly_filename.rfind('.')], 'mp3') - sound_sendfile_url = '{0}.{1}'.format(sound_sendfile_url[:sound_sendfile_url.rfind('.')], 'mp3') + sound_friendly_filename = '{}.{}'.format(sound_friendly_filename[:sound_friendly_filename.rfind('.')], 'mp3') + sound_sendfile_url = '{}.{}'.format(sound_sendfile_url[:sound_sendfile_url.rfind('.')], 'mp3') return sound_path, sound_friendly_filename, sound_sendfile_url diff --git a/utils/pagination.py b/utils/pagination.py index 5a2ec90a00..88beb95f7b 100644 --- a/utils/pagination.py +++ b/utils/pagination.py @@ -37,7 +37,7 @@ def count(self): # If the count was provided return it, otherwise use the if self._count: return self._count - return super(CountProvidedPaginator, self).count + return super().count def paginate(request, qs, items_per_page=20, page_get_name='page', object_count=None): diff --git a/utils/paypal/wrapper.py b/utils/paypal/wrapper.py index 90c8d87fec..1d8be6cdb3 100644 --- a/utils/paypal/wrapper.py +++ b/utils/paypal/wrapper.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - # PayPal python NVP API wrapper class. # This is a sample to help others get started on working # with the PayPal NVP API in Python. @@ -36,13 +34,11 @@ # # if you want to get all info: # paypal.get_transaction_details(response['transactionid']) -from __future__ import print_function from future import standard_library standard_library.install_aliases() -from builtins import object import urllib.request, urllib.parse, urllib.error, cgi -class Paypal(object): +class Paypal: def __init__(self, debug=True): # fill these in with the API values @@ -89,7 +85,7 @@ def query(self, parameters, add_urls=True): response = cgi.parse_qs(urllib.request.urlopen(self.API_ENDPOINT, params_string).read()) # the parsed dict has a list for each value, but all Paypal replies are unique - return dict([(key.lower(), value[0]) for (key,value) in response.items()]) + return {key.lower(): value[0] for (key,value) in response.items()} def set_express_checkout(self, amount): diff --git a/utils/ratelimit.py b/utils/ratelimit.py index 7d9f03b896..af6ac7a003 100644 --- a/utils/ratelimit.py +++ b/utils/ratelimit.py @@ -18,7 +18,6 @@ # See AUTHORS file. # -from builtins import str import ipaddress import logging import random diff --git a/utils/search/__init__.py b/utils/search/__init__.py index 0aa5901838..76d5f5f922 100644 --- a/utils/search/__init__.py +++ b/utils/search/__init__.py @@ -1,4 +1,3 @@ -from __future__ import division # # Freesound is (c) MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA # @@ -19,9 +18,7 @@ # See AUTHORS file. # -from builtins import range from past.utils import old_div -from builtins import object import importlib from django.conf import settings @@ -41,7 +38,7 @@ def get_search_engine(backend_class=settings.SEARCH_ENGINE_BACKEND_CLASS): return getattr(module, class_name)() -class SearchResults(object): +class SearchResults: def __init__(self, docs=None, num_found=-1, start=-1, num_rows=-1, non_grouped_number_of_results=-1, facets=None, highlighting=None, q_time=-1): @@ -145,7 +142,7 @@ def __str__(self): return 'amazing | grace |
amazing | grace |
click me
') - self.assertEqual(u'click me
', ret) + ret = clean_html('click me
') + self.assertEqual('click me
', ret) - ret = clean_html(u'') - self.assertEqual(u'', ret) + ret = clean_html('') + self.assertEqual('', ret) - ret = clean_html(u'hello') - self.assertEqual(u'hello', ret) + ret = clean_html('hello') + self.assertEqual('hello', ret) - ret = clean_html(u'a
b
')
- self.assertEqual(u'
a
b
a
b
')
+ self.assertEqual('
a
b
123hellothere http://www.google.com
123hellothere http://www.google.com
123hellothere http://www.google.com
123hellothere http://www.google.com