Code cleanups

PEP8 cleanups. Add keyword arguments.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2019-05-21 00:56:22 -04:00
parent fbe0e14b82
commit 4baeb6ce7e
219 changed files with 1891 additions and 507 deletions
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
@@ -1,14 +1,11 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import uuid
import uuid
from django.db import models, migrations
from django.core.files.storage import FileSystemStorage
from django.utils.encoding import force_text
import mayan.apps.documents.models
class Migration(migrations.Migration):
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
@@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
def make_existing_documents_not_stubs(apps, schema_editor):
Document = apps.get_model('documents', 'Document')
def operation_make_existing_documents_not_stubs(apps, schema_editor):
Document = apps.get_model(app_label='documents', model_name='Document')
for document in Document.objects.using(schema_editor.connection.alias).all():
document.is_stub = False
@@ -27,5 +26,5 @@ class Migration(migrations.Migration):
),
preserve_default=True,
),
migrations.RunPython(make_existing_documents_not_stubs),
migrations.RunPython(code=operation_make_existing_documents_not_stubs),
]
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import pycountry
@@ -6,8 +5,8 @@ import pycountry
from django.db import migrations
def change_bibliographic_to_terminology(apps, schema_editor):
Document = apps.get_model('documents', 'Document')
def operation_change_bibliographic_to_terminology(apps, schema_editor):
Document = apps.get_model(app_label='documents', model_name='Document')
for document in Document.objects.using(schema_editor.connection.alias).all():
try:
@@ -31,5 +30,5 @@ class Migration(migrations.Migration):
]
operations = [
migrations.RunPython(change_bibliographic_to_terminology),
migrations.RunPython(code=operation_change_bibliographic_to_terminology),
]
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import uuid
@@ -6,8 +5,8 @@ import uuid
from django.db import migrations
def convert_uuid_to_hex(apps, schema_editor):
Document = apps.get_model('documents', 'Document')
def operation_convert_uuid_to_hex(apps, schema_editor):
Document = apps.get_model(app_label='documents', model_name='Document')
for document in Document.objects.using(schema_editor.connection.alias).all():
document.uuid = uuid.UUID(document.uuid).hex
@@ -21,5 +20,5 @@ class Migration(migrations.Migration):
]
operations = [
migrations.RunPython(convert_uuid_to_hex),
migrations.RunPython(code=operation_convert_uuid_to_hex),
]
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import uuid
@@ -6,7 +5,7 @@ import uuid
from django.db import connection, migrations, models
def forwards(apps, schema_editor):
def operation_forwards(apps, schema_editor):
if not schema_editor.connection.vendor == 'oracle':
# Skip this migration for Oracle
# GitHub issue #251
@@ -23,7 +22,7 @@ class Migration(migrations.Migration):
]
operations = [
migrations.RunPython(forwards)
migrations.RunPython(code=operation_forwards)
]
def __init__(self, *args, **kwargs):
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
@@ -14,11 +13,20 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='document',
name='in_trash',
field=models.BooleanField(default=False, verbose_name='In trash?', db_index=True, editable=False),
field=models.BooleanField(
default=False, verbose_name='In trash?', db_index=True,
editable=False
),
),
migrations.AlterField(
model_name='document',
name='is_stub',
field=models.BooleanField(default=True, editable=False, help_text='A document stub is a document with an entry on the database but no file uploaded. This could be an interrupted upload or a deferred upload via the API.', verbose_name='Is stub?', db_index=True),
field=models.BooleanField(
default=True, editable=False,
help_text='A document stub is a document with an entry on '
'the database but no file uploaded. This could be an '
'interrupted upload or a deferred upload via the API.',
verbose_name='Is stub?', db_index=True
),
),
]
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.11 on 2016-12-22 05:34
from __future__ import unicode_literals
from django.db import migrations
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2016-12-31 06:17
from __future__ import unicode_literals
from django.db import migrations, models
@@ -15,6 +13,9 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='document',
name='language',
field=models.CharField(blank=True, default='eng', max_length=8, verbose_name='Language'),
field=models.CharField(
blank=True, default='eng', max_length=8,
verbose_name='Language'
),
),
]
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-07-05 20:08
from __future__ import unicode_literals
from django.db import migrations, models
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-07-06 03:30
from __future__ import unicode_literals
from django.db import migrations, models
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-07-25 11:11
from __future__ import unicode_literals
from django.db import migrations
@@ -14,6 +12,9 @@ class Migration(migrations.Migration):
operations = [
migrations.AlterModelOptions(
name='documentversion',
options={'ordering': ('timestamp',), 'verbose_name': 'Document version', 'verbose_name_plural': 'Document version'},
options={
'ordering': ('timestamp',), 'verbose_name': 'Document version',
'verbose_name_plural': 'Document version'
},
),
]
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-08-23 18:55
from __future__ import unicode_literals
from django.db import migrations, models
@@ -1,13 +1,11 @@
from __future__ import unicode_literals
import uuid
import uuid
import django.core.files.storage
from django.db import migrations, models
from django.utils.encoding import force_text
import mayan.apps.documents.models
class Migration(migrations.Migration):
@@ -6,8 +6,6 @@ import django.core.files.storage
from django.db import migrations, models
from django.utils.encoding import force_text
import mayan.apps.documents.models
class Migration(migrations.Migration):
@@ -19,7 +17,10 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='documentversion',
name='encoding',
field=models.CharField(blank=True, editable=False, max_length=64, null=True, verbose_name='Encoding'),
field=models.CharField(
blank=True, editable=False, max_length=64, null=True,
verbose_name='Encoding'
),
),
migrations.AlterField(
model_name='documentversion',
@@ -33,6 +34,9 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='documentversion',
name='mimetype',
field=models.CharField(blank=True, editable=False, max_length=255, null=True, verbose_name='MIME type'),
field=models.CharField(
blank=True, editable=False, max_length=255, null=True,
verbose_name='MIME type'
),
),
]
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.11 on 2018-08-23 04:52
from __future__ import unicode_literals
from django.conf import settings
@@ -18,7 +16,12 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='FavoriteDocument',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
(
'id', models.AutoField(
auto_created=True, primary_key=True, serialize=False,
verbose_name='ID'
)
),
],
options={
'verbose_name': 'Favorite document',
@@ -27,21 +30,35 @@ class Migration(migrations.Migration):
),
migrations.AlterModelOptions(
name='document',
options={'ordering': ('label',), 'verbose_name': 'Document', 'verbose_name_plural': 'Documents'},
options={
'ordering': ('label',), 'verbose_name': 'Document',
'verbose_name_plural': 'Documents'
},
),
migrations.AlterField(
model_name='recentdocument',
name='document',
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='recent', to='documents.Document', verbose_name='Document'),
field=models.ForeignKey(
editable=False, on_delete=django.db.models.deletion.CASCADE,
related_name='recent', to='documents.Document',
verbose_name='Document'
),
),
migrations.AddField(
model_name='favoritedocument',
name='document',
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='favorites', to='documents.Document', verbose_name='Document'),
field=models.ForeignKey(
editable=False, on_delete=django.db.models.deletion.CASCADE,
related_name='favorites', to='documents.Document',
verbose_name='Document'
),
),
migrations.AddField(
model_name='favoritedocument',
name='user',
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='User'),
field=models.ForeignKey(
editable=False, on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL, verbose_name='User'
),
),
]
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.11 on 2018-09-17 06:45
from __future__ import unicode_literals
from django.db import migrations, models
@@ -16,66 +14,120 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='document',
name='date_added',
field=models.DateTimeField(auto_now_add=True, db_index=True, help_text='The server date and time when the document was finally processed and added to the system.', verbose_name='Added'),
field=models.DateTimeField(
auto_now_add=True, db_index=True, help_text='The server '
'date and time when the document was finally processed '
'and added to the system.', verbose_name='Added'
),
),
migrations.AlterField(
model_name='document',
name='deleted_date_time',
field=models.DateTimeField(blank=True, help_text='The server date and time when the document was moved to the trash.', null=True, verbose_name='Date and time trashed'),
field=models.DateTimeField(
blank=True, help_text='The server date and time when the '
'document was moved to the trash.', null=True,
verbose_name='Date and time trashed'
),
),
migrations.AlterField(
model_name='document',
name='description',
field=models.TextField(blank=True, default='', help_text='An optional short text describing a document.', verbose_name='Description'),
field=models.TextField(
blank=True, default='', help_text='An optional short text '
'describing a document.', verbose_name='Description'
),
),
migrations.AlterField(
model_name='document',
name='in_trash',
field=models.BooleanField(db_index=True, default=False, editable=False, help_text='Whether or not this document is in the trash.', verbose_name='In trash?'),
field=models.BooleanField(
db_index=True, default=False, editable=False,
help_text='Whether or not this document is in the trash.',
verbose_name='In trash?'
),
),
migrations.AlterField(
model_name='document',
name='label',
field=models.CharField(blank=True, db_index=True, default='', help_text='The name of the document.', max_length=255, verbose_name='Label'),
field=models.CharField(
blank=True, db_index=True, default='', help_text='The name '
'of the document.', max_length=255, verbose_name='Label'
),
),
migrations.AlterField(
model_name='document',
name='language',
field=models.CharField(blank=True, default=b'eng', help_text='The dominant language in the document.', max_length=8, verbose_name='Language'),
field=models.CharField(
blank=True, default=b'eng', help_text='The dominant '
'language in the document.', max_length=8,
verbose_name='Language'
),
),
migrations.AlterField(
model_name='document',
name='uuid',
field=models.UUIDField(default=uuid.uuid4, editable=False, help_text='UUID of a document, universally Unique ID. An unique identifiergenerated for each document.', verbose_name='UUID'),
field=models.UUIDField(
default=uuid.uuid4, editable=False, help_text='UUID of a '
'document, universally Unique ID. An unique identifier '
'generated for each document.', verbose_name='UUID'
),
),
migrations.AlterField(
model_name='documenttype',
name='label',
field=models.CharField(help_text='The name of the document type.', max_length=32, unique=True, verbose_name='Label'),
field=models.CharField(
help_text='The name of the document type.', max_length=32,
unique=True, verbose_name='Label'
),
),
migrations.AlterField(
model_name='documentversion',
name='checksum',
field=models.CharField(blank=True, db_index=True, editable=False, help_text="A hash/checkdigit/fingerprint generated from the document's binary data. Only identical documents will have the same checksum.", max_length=64, null=True, verbose_name='Checksum'),
field=models.CharField(
blank=True, db_index=True, editable=False,
help_text="A hash/checkdigit/fingerprint generated from "
"the document's binary data. Only identical documents will "
"have the same checksum.", max_length=64, null=True,
verbose_name='Checksum'
),
),
migrations.AlterField(
model_name='documentversion',
name='comment',
field=models.TextField(blank=True, default='', help_text='An optional short text describing the document version.', verbose_name='Comment'),
field=models.TextField(
blank=True, default='', help_text='An optional short text '
'describing the document version.', verbose_name='Comment'
),
),
migrations.AlterField(
model_name='documentversion',
name='encoding',
field=models.CharField(blank=True, editable=False, help_text='The document version file encoding. binary 7-bit, binary 8-bit, text, base64, etc.', max_length=64, null=True, verbose_name='Encoding'),
field=models.CharField(
blank=True, editable=False, help_text='The document version '
'file encoding. binary 7-bit, binary 8-bit, text, '
'base64, etc.', max_length=64, null=True,
verbose_name='Encoding'
),
),
migrations.AlterField(
model_name='documentversion',
name='mimetype',
field=models.CharField(blank=True, editable=False, help_text='The document version\'s file mimetype. MIME types are a standard way to describe the format of a file, in this case the file format of the document. Some examples: "text/plain" or "image/jpeg". ', max_length=255, null=True, verbose_name='MIME type'),
field=models.CharField(
blank=True, editable=False, help_text='The document '
'version\'s file mimetype. MIME types are a standard way '
'to describe the format of a file, in this case the file '
'format of the document. Some examples: "text/plain" '
'or "image/jpeg". ', max_length=255, null=True,
verbose_name='MIME type'
),
),
migrations.AlterField(
model_name='documentversion',
name='timestamp',
field=models.DateTimeField(auto_now_add=True, db_index=True, help_text='The server date and time when the document version was processed.', verbose_name='Timestamp'),
field=models.DateTimeField(
auto_now_add=True, db_index=True, help_text='The server '
'date and time when the document version was processed.',
verbose_name='Timestamp'
),
),
]
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.11 on 2018-09-17 07:13
from __future__ import unicode_literals
from django.db import migrations, models
@@ -15,6 +13,9 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='documenttype',
name='label',
field=models.CharField(help_text='The name of the document type.', max_length=96, unique=True, verbose_name='Label'),
field=models.CharField(
help_text='The name of the document type.', max_length=96,
unique=True, verbose_name='Label'
),
),
]
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.11 on 2018-09-17 07:37
from __future__ import unicode_literals
from django.db import migrations, models
@@ -16,12 +14,17 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='documentpagecachedimage',
name='datetime',
field=models.DateTimeField(auto_now_add=True, db_index=True, default=django.utils.timezone.now, verbose_name='Date time'),
field=models.DateTimeField(
auto_now_add=True, db_index=True,
default=django.utils.timezone.now, verbose_name='Date time'
),
preserve_default=False,
),
migrations.AddField(
model_name='documentpagecachedimage',
name='file_size',
field=models.PositiveIntegerField(db_index=True, default=0, verbose_name='File size'),
field=models.PositiveIntegerField(
db_index=True, default=0, verbose_name='File size'
),
),
]
@@ -239,7 +239,6 @@ class DocumentPage(models.Model):
storage_documentimagecache.delete(cache_filename)
raise
def invalidate_cache(self):
storage_documentimagecache.delete(self.cache_filename)
for cached_image in self.cached_images.all():
@@ -15,4 +15,3 @@ class DocumentStatisticsTestCase(BaseTestCase):
'Error executing: {}; {}'.format(statistic, exception)
)
raise