Python 3
authorRadek Czajka <rczajka@rczajka.pl>
Sun, 29 Mar 2020 22:44:40 +0000 (00:44 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Sun, 29 Mar 2020 22:44:40 +0000 (00:44 +0200)
src/apiclient/migrations/0001_initial.py
src/apiclient/urls.py
src/archive/migrations/0001_initial.py
src/archive/models.py
src/archive/settings.py
src/archive/tasks.py
src/archive/views.py
src/audiobooks/__init__.py
src/audiobooks/celery.py
src/audiobooks/settings.py

index 5d62406..ee0c56c 100644 (file)
@@ -1,6 +1,3 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
 from django.db import models, migrations
 from django.conf import settings
 
index 8e93697..09d4712 100755 (executable)
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 from django.conf.urls import url
 from . import views
 
index c1f2837..75c8b92 100644 (file)
@@ -1,6 +1,3 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
 from django.db import models, migrations
 import archive.utils
 import archive.models
@@ -19,7 +16,7 @@ class Migration(migrations.Migration):
                 ('source_file', models.FileField(verbose_name='source file', max_length=255, editable=False, upload_to=archive.models.source_upload_to)),
                 ('source_sha1', models.CharField(max_length=40, editable=False)),
                 ('title', models.CharField(max_length=255, verbose_name='title')),
-                ('part_name', models.CharField(default=b'', help_text='eg. chapter in a novel', max_length=255, verbose_name='part name', blank=True)),
+                ('part_name', models.CharField(default='', help_text='eg. chapter in a novel', max_length=255, verbose_name='part name', blank=True)),
                 ('index', models.IntegerField(default=0, verbose_name='index')),
                 ('parts_count', models.IntegerField(default=1, verbose_name='parts count')),
                 ('artist', models.CharField(max_length=255, verbose_name='artist')),
@@ -32,13 +29,13 @@ class Migration(migrations.Migration):
                 ('mp3_status', models.SmallIntegerField(null=True, editable=False, choices=[(1, 'Waiting'), (2, 'Encoding'), (3, 'Tagging'), (4, 'Sending')])),
                 ('mp3_task', models.CharField(max_length=64, null=True, editable=False)),
                 ('mp3_tags', models.TextField(null=True, editable=False)),
-                ('mp3_file', models.FileField(storage=archive.utils.OverwriteStorage(), upload_to=b'archive/final', null=True, editable=False)),
+                ('mp3_file', models.FileField(storage=archive.utils.OverwriteStorage(), upload_to='archive/final', null=True, editable=False)),
                 ('mp3_published_tags', models.TextField(null=True, editable=False)),
                 ('mp3_published', models.DateTimeField(null=True, editable=False)),
                 ('ogg_status', models.SmallIntegerField(null=True, editable=False, choices=[(1, 'Waiting'), (2, 'Encoding'), (3, 'Tagging'), (4, 'Sending')])),
                 ('ogg_task', models.CharField(max_length=64, null=True, editable=False)),
                 ('ogg_tags', models.TextField(null=True, editable=False)),
-                ('ogg_file', models.FileField(storage=archive.utils.OverwriteStorage(), upload_to=b'archive/final', null=True, editable=False)),
+                ('ogg_file', models.FileField(storage=archive.utils.OverwriteStorage(), upload_to='archive/final', null=True, editable=False)),
                 ('ogg_published_tags', models.TextField(null=True, editable=False)),
                 ('ogg_published', models.DateTimeField(null=True, editable=False)),
             ],
@@ -53,8 +50,8 @@ class Migration(migrations.Migration):
             name='Project',
             fields=[
                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
-                ('name', models.CharField(unique=True, max_length=128, verbose_name=b'Nazwa', db_index=True)),
-                ('sponsors', models.TextField(null=True, verbose_name=b'Sponsorzy', blank=True)),
+                ('name', models.CharField(unique=True, max_length=128, verbose_name='Nazwa', db_index=True)),
+                ('sponsors', models.TextField(null=True, verbose_name='Sponsorzy', blank=True)),
             ],
             options={
                 'ordering': ('name',),
index 56b61af..4a1d763 100644 (file)
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 import os.path
 
 from django.db import models
@@ -9,8 +8,6 @@ from archive.constants import status
 from archive.settings import FILES_SAVE_PATH, ADVERT, LICENSE, ORGANIZATION, PROJECT
 from archive.utils import OverwriteStorage, sha1_file
 
-# Create your models here.
-
 
 class Project(models.Model):
     """ an audiobook project, needed for specyfing sponsors """
@@ -23,7 +20,7 @@ class Project(models.Model):
         verbose_name_plural = _("projects")
         ordering = ("name",)
 
-    def __unicode__(self):
+    def __str__(self):
         return self.name
 
 
@@ -70,7 +67,7 @@ class Audiobook(models.Model):
         verbose_name_plural = _("audiobooks")
         ordering = ("title",)
 
-    def __unicode__(self):
+    def __str__(self):
         return self.title
 
     def get_mp3_tags(self): return json.loads(self.mp3_tags) if self.mp3_tags else None
@@ -110,14 +107,14 @@ class Audiobook(models.Model):
     def new_publish_tags(self):
         title = self.title
         if self.translator:
-            title += u' (tłum. %s)' % self.translator
+            title += ' (tłum. %s)' % self.translator
 
-        copyright = u"%s %s. Licensed to the public under %s verify at %s" % (
+        copyright = "%s %s. Licensed to the public under %s verify at %s" % (
                 self.date, ORGANIZATION, LICENSE, self.url)
 
-        comment = u"Audiobook nagrany w ramach projektu %s%s.\n%s" % (
+        comment = "Audiobook nagrany w ramach projektu %s%s.\n%s" % (
                     self.project.name,
-                    u" finansowanego przez %s" % self.project.sponsors if self.project.sponsors else "",
+                    " finansowanego przez %s" % self.project.sponsors if self.project.sponsors else "",
                     ADVERT)
 
         tags = {
@@ -129,8 +126,8 @@ class Audiobook(models.Model):
             'contact': self.url,
             'copyright': copyright,
             'date': self.date,
-            'genre': u'Speech',
-            'language': u'pol',
+            'genre': 'Speech',
+            'language': 'pol',
             'license': LICENSE,
             'organization': ORGANIZATION,
             'title': title,
index 747287d..5c8e5f1 100644 (file)
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
 import os.path
 from django.conf import settings
 
@@ -55,22 +53,22 @@ UPLOAD_URL = getattr(
 try:
     PROJECT = settings.ARCHIVE_PROJECT
 except AttributeError:
-    PROJECT = u'Wolne Lektury'
+    PROJECT = 'Wolne Lektury'
 
 try:
     LICENSE = settings.ARCHIVE_LICENSE
 except AttributeError:
-    LICENSE = u'http://creativecommons.org/licenses/by-sa/3.0/deed.pl'
+    LICENSE = 'http://creativecommons.org/licenses/by-sa/3.0/deed.pl'
 
 try:
     ORGANIZATION = settings.ARCHIVE_ORGANIZATION
 except AttributeError:
-    ORGANIZATION = u'Fundacja Nowoczesna Polska'
+    ORGANIZATION = 'Fundacja Nowoczesna Polska'
 
 try:
     ADVERT = settings.ARCHIVE_ADVERT
 except AttributeError:
-    ADVERT = u"""
+    ADVERT = """
 Przekaż 1% podatku na rozwój Wolnych Lektur:
 Fundacja Nowoczesna Polska
 KRS 0000070056
index 1eeeb28..13bf5f2 100644 (file)
@@ -128,9 +128,9 @@ class Mp3Task(AudioFormatTask):
         return tag(encoding=1, text=text)
     def id3_url(tag, text):
         return tag(url=text)
-    def id3_comment(tag, text, lang=u'pol'):
-        return tag(encoding=1, lang=lang, desc=u'', text=text)
-    def id3_priv(tag, text, what=u''):
+    def id3_comment(tag, text, lang='pol'):
+        return tag(encoding=1, lang=lang, desc='', text=text)
+    def id3_priv(tag, text, what=''):
         return tag(owner='wolnelektury.pl?%s' % what, data=text.encode('utf-8'))
 
     TAG_MAP = {
@@ -179,7 +179,7 @@ class Mp3Task(AudioFormatTask):
         if COVER_IMAGE:
             mime = mimetypes.guess_type(COVER_IMAGE)
             f = open(COVER_IMAGE)
-            audio.add(id3.APIC(encoding=0, mime=mime, type=3, desc=u'', data=f.read()))
+            audio.add(id3.APIC(encoding=0, mime=mime, type=3, desc='', data=f.read()))
             f.close()
 
         audio.save()
index fc3a7e5..f237fab 100644 (file)
@@ -3,7 +3,7 @@
 from datetime import datetime
 import os
 import os.path
-from urllib import quote
+from urllib.parse import quote
 
 from archive import settings
 from django.contrib.auth import logout
index e331a74..fb989c4 100644 (file)
@@ -1,5 +1,3 @@
-from __future__ import absolute_import, unicode_literals
-
 from .celery import app as celery_app
 
 __all__ = ('celery_app',)
index 8da78a4..5b51228 100644 (file)
@@ -1,4 +1,3 @@
-from __future__ import absolute_import, unicode_literals
 import os
 from celery import Celery
 
index eab421d..46e73d3 100644 (file)
@@ -1,5 +1,4 @@
 # Django settings for audiobooks project.
-# -*- coding: utf-8 -*-
 
 import os
 PROJECT_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))