diff --git a/contrib/scripts/process_messages.py b/contrib/scripts/process_messages.py index 01fde2e155..b0069300ee 100755 --- a/contrib/scripts/process_messages.py +++ b/contrib/scripts/process_messages.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -import sys import os import optparse diff --git a/manage.py b/manage.py index 47a0084392..c8d9c5d18b 100755 --- a/manage.py +++ b/manage.py @@ -8,4 +8,3 @@ if __name__ == "__main__": from django.core.management import execute_from_command_line execute_from_command_line(sys.argv) - diff --git a/mayan/apps/appearance/apps.py b/mayan/apps/appearance/apps.py index 44382f33e2..8a6c0608a7 100644 --- a/mayan/apps/appearance/apps.py +++ b/mayan/apps/appearance/apps.py @@ -1,6 +1,5 @@ from __future__ import unicode_literals -from django import apps from django.utils.translation import ugettext_lazy as _ from common import MayanAppConfig diff --git a/mayan/apps/checkouts/tests/test_models.py b/mayan/apps/checkouts/tests/test_models.py index aaf87bce80..72f8fb03b5 100644 --- a/mayan/apps/checkouts/tests/test_models.py +++ b/mayan/apps/checkouts/tests/test_models.py @@ -13,7 +13,7 @@ from authentication.tests.literals import ( ) from documents.models import DocumentType from documents.tests.literals import ( - TEST_DOCUMENT_TYPE, TEST_DOCUMENT_PATH, TEST_SMALL_DOCUMENT_PATH + TEST_DOCUMENT_TYPE, TEST_SMALL_DOCUMENT_PATH ) from ..exceptions import ( diff --git a/mayan/apps/common/tests/test_views.py b/mayan/apps/common/tests/test_views.py index c4ded1802a..c3ce3f6ed4 100644 --- a/mayan/apps/common/tests/test_views.py +++ b/mayan/apps/common/tests/test_views.py @@ -7,8 +7,7 @@ from django.test.client import Client from django.test import TestCase from documents.tests.literals import ( - TEST_ADMIN_PASSWORD, TEST_ADMIN_USERNAME, TEST_ADMIN_EMAIL, - TEST_SMALL_DOCUMENT_PATH, TEST_DOCUMENT_TYPE + TEST_ADMIN_PASSWORD, TEST_ADMIN_USERNAME, TEST_ADMIN_EMAIL ) diff --git a/mayan/apps/common/views.py b/mayan/apps/common/views.py index 95c3e4ad64..a094c17136 100644 --- a/mayan/apps/common/views.py +++ b/mayan/apps/common/views.py @@ -159,10 +159,10 @@ class PackagesLicensesView(SimpleView): # Use a function so that PackagesLicensesForm get initialized at every # request return { - 'form': PackagesLicensesForm(), - 'read_only': True, - 'title': _('Other packages licenses'), - } + 'form': PackagesLicensesForm(), + 'read_only': True, + 'title': _('Other packages licenses'), + } class SetupListView(TemplateView): diff --git a/mayan/apps/converter/classes.py b/mayan/apps/converter/classes.py index 763cbca155..11922d0cfe 100644 --- a/mayan/apps/converter/classes.py +++ b/mayan/apps/converter/classes.py @@ -2,7 +2,6 @@ from __future__ import unicode_literals import logging import os -import subprocess import tempfile try: @@ -131,7 +130,7 @@ class ConverterBase(object): if self.mime_type == 'text/plain': libreoffice_filter = 'Text (encoded):UTF8,LF,,,' - args=(input_filepath, '--outdir', setting_temporary_directory.value) + args = (input_filepath, '--outdir', setting_temporary_directory.value) kwargs = {'_env': {'HOME': setting_temporary_directory.value}} diff --git a/mayan/apps/converter/models.py b/mayan/apps/converter/models.py index 00d4a538c5..3f27dab0ad 100644 --- a/mayan/apps/converter/models.py +++ b/mayan/apps/converter/models.py @@ -28,18 +28,20 @@ class Transformation(models.Model): content_object = generic.GenericForeignKey('content_type', 'object_id') order = models.PositiveIntegerField( - blank=True, db_index=True, default=0, - help_text=_('Order in which the transformations will be executed. If left unchanged, an automatic order value will be assigned.'), - verbose_name=_('Order') + blank=True, db_index=True, default=0, help_text=_( + 'Order in which the transformations will be executed. If left ' + 'unchanged, an automatic order value will be assigned.' + ), verbose_name=_('Order') ) name = models.CharField( choices=BaseTransformation.get_transformation_choices(), max_length=128, verbose_name=_('Name') ) arguments = models.TextField( - blank=True, - help_text=_('Enter the arguments for the transformation as a YAML dictionary. ie: {"degrees": 180}'), - validators=[YAMLValidator()], verbose_name=_('Arguments') + blank=True, help_text=_( + 'Enter the arguments for the transformation as a YAML ' + 'dictionary. ie: {"degrees": 180}' + ), validators=[YAMLValidator()], verbose_name=_('Arguments') ) objects = TransformationManager() diff --git a/mayan/apps/document_indexing/migrations/0010_documentindexinstancenode_indexinstance.py b/mayan/apps/document_indexing/migrations/0010_documentindexinstancenode_indexinstance.py index 706ff6d0ae..e9368591fb 100644 --- a/mayan/apps/document_indexing/migrations/0010_documentindexinstancenode_indexinstance.py +++ b/mayan/apps/document_indexing/migrations/0010_documentindexinstancenode_indexinstance.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import models, migrations +from django.db import migrations class Migration(migrations.Migration): diff --git a/mayan/apps/documents/models.py b/mayan/apps/documents/models.py index 8a3c66c57f..d2a11ba5ff 100644 --- a/mayan/apps/documents/models.py +++ b/mayan/apps/documents/models.py @@ -3,7 +3,6 @@ from __future__ import unicode_literals import base64 import hashlib import logging -import os import uuid from django.contrib.auth.models import User @@ -15,7 +14,6 @@ from django.utils.timezone import now from django.utils.translation import ugettext, ugettext_lazy as _ from common.literals import TIME_DELTA_UNIT_CHOICES -from common.settings import setting_temporary_directory from converter import ( converter_class, TransformationResize, TransformationRotate, TransformationZoom diff --git a/mayan/apps/documents/tasks.py b/mayan/apps/documents/tasks.py index 11356f6755..616fdc01d4 100644 --- a/mayan/apps/documents/tasks.py +++ b/mayan/apps/documents/tasks.py @@ -15,9 +15,7 @@ from .literals import ( UPDATE_PAGE_COUNT_RETRY_DELAY, UPLOAD_NEW_VERSION_RETRY_DELAY, NEW_DOCUMENT_RETRY_DELAY, STUB_EXPIRATION_INTERVAL ) -from .models import ( - DeletedDocument, Document, DocumentPage, DocumentType, DocumentVersion -) +from .models import Document, DocumentPage, DocumentType, DocumentVersion logger = logging.getLogger(__name__) diff --git a/mayan/apps/documents/tests/test_models.py b/mayan/apps/documents/tests/test_models.py index 0a02871b2f..1d2919dcb6 100644 --- a/mayan/apps/documents/tests/test_models.py +++ b/mayan/apps/documents/tests/test_models.py @@ -5,8 +5,6 @@ import time from django.core.files import File from django.test import TestCase, override_settings -from common.literals import TIME_DELTA_UNIT_DAYS - from .literals import ( TEST_DOCUMENT_TYPE, TEST_DOCUMENT_PATH, TEST_MULTI_PAGE_TIFF_PATH, TEST_OFFICE_DOCUMENT_PATH, TEST_SMALL_DOCUMENT_PATH diff --git a/mayan/apps/dynamic_search/forms.py b/mayan/apps/dynamic_search/forms.py index 7fbb43f87b..aa37ce1c48 100644 --- a/mayan/apps/dynamic_search/forms.py +++ b/mayan/apps/dynamic_search/forms.py @@ -17,4 +17,6 @@ class AdvancedSearchForm(forms.Form): class SearchForm(forms.Form): - q = forms.CharField(max_length=128, label=_('Search terms'), required=False) + q = forms.CharField( + max_length=128, label=_('Search terms'), required=False + ) diff --git a/mayan/apps/dynamic_search/models.py b/mayan/apps/dynamic_search/models.py index d2495d34b3..9afc0c97dc 100644 --- a/mayan/apps/dynamic_search/models.py +++ b/mayan/apps/dynamic_search/models.py @@ -35,7 +35,9 @@ class RecentSearch(models.Model): from .classes import SearchModel document_search = SearchModel.get('documents.Document') - query_dict = urlparse.parse_qs(urllib.unquote_plus(smart_str(self.query))) + query_dict = urlparse.parse_qs( + urllib.unquote_plus(smart_str(self.query)) + ) if self.is_advanced(): # Advanced search diff --git a/mayan/apps/dynamic_search/serializers.py b/mayan/apps/dynamic_search/serializers.py index 2f2b3178d0..0e49d1b9bf 100644 --- a/mayan/apps/dynamic_search/serializers.py +++ b/mayan/apps/dynamic_search/serializers.py @@ -8,7 +8,9 @@ from .models import RecentSearch class RecentSearchSerializer(serializers.HyperlinkedModelSerializer): - url = serializers.HyperlinkedIdentityField(view_name='rest_api:recentsearch-detail') + url = serializers.HyperlinkedIdentityField( + view_name='rest_api:recentsearch-detail' + ) user = UserSerializer() class Meta: diff --git a/mayan/apps/dynamic_search/views.py b/mayan/apps/dynamic_search/views.py index 6cf24b8605..bceb6665bf 100644 --- a/mayan/apps/dynamic_search/views.py +++ b/mayan/apps/dynamic_search/views.py @@ -44,7 +44,9 @@ class ResultsView(SingleObjectListView): # Only do search if there is user input, otherwise just render # the template with the extra_context - queryset, ids, timedelta = document_search.search(self.request.GET, self.request.user) + queryset, ids, timedelta = document_search.search( + self.request.GET, self.request.user + ) return queryset diff --git a/mayan/apps/folders/migrations/0004_documentfolder.py b/mayan/apps/folders/migrations/0004_documentfolder.py index ad0a7ced49..ecbd9b212d 100644 --- a/mayan/apps/folders/migrations/0004_documentfolder.py +++ b/mayan/apps/folders/migrations/0004_documentfolder.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import models, migrations +from django.db import migrations class Migration(migrations.Migration): diff --git a/mayan/apps/mailer/views.py b/mayan/apps/mailer/views.py index 5144323820..c74d602d7b 100644 --- a/mayan/apps/mailer/views.py +++ b/mayan/apps/mailer/views.py @@ -38,7 +38,9 @@ def send_document_link(request, document_id=None, document_id_list=None, as_atta if document_id: documents = [get_object_or_404(Document, pk=document_id)] elif document_id_list: - documents = [get_object_or_404(Document, pk=document_id) for document_id in document_id_list.split(',')] + documents = [ + get_object_or_404(Document, pk=document_id) for document_id in document_id_list.split(',') + ] if as_attachment: permission = permission_mailing_send_document @@ -48,15 +50,25 @@ def send_document_link(request, document_id=None, document_id_list=None, as_atta try: Permission.check_permissions(request.user, (permission,)) except PermissionDenied: - documents = AccessControlList.objects.filter_by_access(permission, request.user, documents) + documents = AccessControlList.objects.filter_by_access( + permission, request.user, documents + ) if not documents: messages.error(request, _('Must provide at least one document.')) - return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse(settings.LOGIN_REDIRECT_URL))) + return HttpResponseRedirect( + request.META.get( + 'HTTP_REFERER', reverse(settings.LOGIN_REDIRECT_URL) + ) + ) post_action_redirect = reverse('documents:document_list_recent') - next = request.POST.get('next', request.GET.get('next', request.META.get('HTTP_REFERER', post_action_redirect))) + next = request.POST.get( + 'next', request.GET.get( + 'next', request.META.get('HTTP_REFERER', post_action_redirect) + ) + ) for document in documents: document.add_as_recent_document_for_user(request.user) @@ -77,7 +89,15 @@ def send_document_link(request, document_id=None, document_id_list=None, as_atta subject_template = Template(form.cleaned_data['subject']) subject_text = strip_tags(subject_template.render(context)) - task_send_document.apply_async(args=(subject_text, body_text_content, request.user.email, form.cleaned_data['email']), kwargs={'document_id': document.pk, 'as_attachment': as_attachment}) + task_send_document.apply_async( + args=( + subject_text, body_text_content, request.user.email, + form.cleaned_data['email'] + ), kwargs={ + 'document_id': document.pk, + 'as_attachment': as_attachment + } + ) # TODO: Pluralize messages.success(request, _('Successfully queued for delivery via email.')) @@ -103,5 +123,7 @@ def send_document_link(request, document_id=None, document_id_list=None, as_atta else: context['title'] = _('Email links for documents: %s') % ', '.join([unicode(d) for d in documents]) - return render_to_response('appearance/generic_form.html', context, - context_instance=RequestContext(request)) + return render_to_response( + 'appearance/generic_form.html', context, + context_instance=RequestContext(request) + ) diff --git a/mayan/apps/metadata/apps.py b/mayan/apps/metadata/apps.py index 39c28f4cb7..197e735a26 100644 --- a/mayan/apps/metadata/apps.py +++ b/mayan/apps/metadata/apps.py @@ -137,7 +137,9 @@ class MetadataApp(MayanAppConfig): ) SourceColumn( source=DocumentMetadata, label=_('Required'), - func=lambda context: two_state_template(context['object'].is_required) + func=lambda context: two_state_template( + context['object'].is_required + ) ) app.conf.CELERY_QUEUES.append( diff --git a/mayan/apps/metadata/forms.py b/mayan/apps/metadata/forms.py index 40a15bb90f..23503cc250 100644 --- a/mayan/apps/metadata/forms.py +++ b/mayan/apps/metadata/forms.py @@ -18,7 +18,9 @@ class MetadataForm(forms.Form): self.document_type = kwargs['initial'].pop('document_type', None) required_string = '' - required = self.metadata_type.get_required_for(document_type=self.document_type) + required = self.metadata_type.get_required_for( + document_type=self.document_type + ) if required: self.fields['value'].required = True required_string = ' (%s)' % _('Required') @@ -66,7 +68,9 @@ class MetadataForm(forms.Form): ) def clean_value(self): - return self.metadata_type.validate_value(document_type=self.document_type, value=self.cleaned_data['value']) + return self.metadata_type.validate_value( + document_type=self.document_type, value=self.cleaned_data['value'] + ) id = forms.CharField(label=_('ID'), widget=forms.HiddenInput) diff --git a/mayan/apps/metadata/urls.py b/mayan/apps/metadata/urls.py index 4468843a89..e0eea49a8a 100644 --- a/mayan/apps/metadata/urls.py +++ b/mayan/apps/metadata/urls.py @@ -18,7 +18,9 @@ from .views import ( urlpatterns = patterns( 'metadata.views', - url(r'^(?P\d+)/edit/$', 'metadata_edit', name='metadata_edit'), + url( + r'^(?P\d+)/edit/$', 'metadata_edit', name='metadata_edit' + ), url( r'^(?P\d+)/view/$', DocumentMetadataListView.as_view(), name='metadata_view' diff --git a/mayan/apps/mimetype/apps.py b/mayan/apps/mimetype/apps.py index 38f3f1758c..cbb878fc42 100644 --- a/mayan/apps/mimetype/apps.py +++ b/mayan/apps/mimetype/apps.py @@ -1,13 +1,12 @@ from __future__ import unicode_literals -from django import apps from django.utils.translation import ugettext_lazy as _ from common import MayanAppConfig from common.classes import Package -class MIMETypesApp(apps.AppConfig): +class MIMETypesApp(MayanAppConfig): name = 'mimetype' verbose_name = _('MIME types') diff --git a/mayan/apps/ocr/api_views.py b/mayan/apps/ocr/api_views.py index f06cb01dcd..ded56e8ed8 100644 --- a/mayan/apps/ocr/api_views.py +++ b/mayan/apps/ocr/api_views.py @@ -1,17 +1,9 @@ from __future__ import absolute_import, unicode_literals -from django.core.exceptions import PermissionDenied -from django.shortcuts import get_object_or_404 - from rest_framework import generics, status from rest_framework.response import Response -from rest_framework.settings import api_settings -from rest_framework.views import APIView -from acls.models import AccessControlList from documents.models import Document, DocumentPage, DocumentVersion -from permissions import Permission -from rest_api.filters import MayanObjectPermissionsFilter from rest_api.permissions import MayanPermission from .models import DocumentPageContent diff --git a/mayan/apps/ocr/parsers.py b/mayan/apps/ocr/parsers.py index deab577b7d..bc21031037 100644 --- a/mayan/apps/ocr/parsers.py +++ b/mayan/apps/ocr/parsers.py @@ -75,7 +75,9 @@ class Parser(object): raise NoMIMETypeMatch def process_document_version(self, document_version): - logger.info('Starting parsing for document version: %s', document_version) + logger.info( + 'Starting parsing for document version: %s', document_version + ) logger.debug('document version: %d', document_version.pk) for document_page in document_version.pages.all(): @@ -124,7 +126,9 @@ class PopplerParser(Parser): def __init__(self): self.pdftotext_path = setting_pdftotext_path.value if not os.path.exists(self.pdftotext_path): - error_message = _('Cannot find pdftotext executable at: %s') % self.pdftotext_path + error_message = _( + 'Cannot find pdftotext executable at: %s' + ) % self.pdftotext_path logger.error(error_message) raise ParserError(error_message) @@ -178,9 +182,13 @@ class PDFMinerParser(Parser): with BytesIO() as string_buffer: rsrcmgr = PDFResourceManager() - device = TextConverter(rsrcmgr, outfp=string_buffer, laparams=LAParams()) + device = TextConverter( + rsrcmgr, outfp=string_buffer, laparams=LAParams() + ) interpreter = PDFPageInterpreter(rsrcmgr, device) - page = PDFPage.get_pages(file_object, maxpages=1, pagenos=(page_number - 1,)) + page = PDFPage.get_pages( + file_object, maxpages=1, pagenos=(page_number - 1,) + ) interpreter.process_page(page.next()) device.close() @@ -189,5 +197,6 @@ class PDFMinerParser(Parser): return string_buffer.getvalue() Parser.register( - mimetypes=('application/pdf',), parser_classes=(PopplerParser, PDFMinerParser) + mimetypes=('application/pdf',), + parser_classes=(PopplerParser, PDFMinerParser) ) diff --git a/mayan/apps/ocr/urls.py b/mayan/apps/ocr/urls.py index 492aa2d049..554e3fced8 100644 --- a/mayan/apps/ocr/urls.py +++ b/mayan/apps/ocr/urls.py @@ -58,13 +58,12 @@ api_urls = patterns( name='document-ocr-submit-view' ), url( - r'^document_version/(?P\d+)/submit/$', APIDocumentVersionOCRView.as_view(), + r'^document_version/(?P\d+)/submit/$', + APIDocumentVersionOCRView.as_view(), name='document-version-ocr-submit-view' ), url( r'^page/(?P\d+)/content/$', APIDocumentPageContentView.as_view(), name='document-page-content-view' ), - ) - diff --git a/mayan/apps/tags/api_views.py b/mayan/apps/tags/api_views.py index 7ce9aa5352..a4d2de5cb1 100644 --- a/mayan/apps/tags/api_views.py +++ b/mayan/apps/tags/api_views.py @@ -160,7 +160,9 @@ class APIDocumentTagListView(generics.ListCreateAPIView): Attach a tag to a document. """ - return super(APIDocumentTagListView, self).post(request, *args, **kwargs) + return super( + APIDocumentTagListView, self + ).post(request, *args, **kwargs) class APIDocumentTagView(generics.RetrieveDestroyAPIView): @@ -176,7 +178,9 @@ class APIDocumentTagView(generics.RetrieveDestroyAPIView): Remove a tag from the selected document. """ - return super(APIDocumentTagView, self).delete(request, *args, **kwargs) + return super( + APIDocumentTagView, self + ).delete(request, *args, **kwargs) def get(self, *args, **kwargs): """ diff --git a/mayan/apps/tags/apps.py b/mayan/apps/tags/apps.py index 362f3c3616..7a95c81e33 100644 --- a/mayan/apps/tags/apps.py +++ b/mayan/apps/tags/apps.py @@ -37,7 +37,10 @@ class TagsApp(MayanAppConfig): APIEndPoint(app=self, version_string='1') - Document.add_to_class('attached_tags', lambda document: DocumentTag.objects.filter(documents=document)) + Document.add_to_class( + 'attached_tags', + lambda document: DocumentTag.objects.filter(documents=document) + ) ModelPermission.register( model=Document, permissions=( diff --git a/mayan/apps/tags/migrations/0006_documenttag.py b/mayan/apps/tags/migrations/0006_documenttag.py index c282d53177..bd1094dff5 100644 --- a/mayan/apps/tags/migrations/0006_documenttag.py +++ b/mayan/apps/tags/migrations/0006_documenttag.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import models, migrations +from django.db import migrations class Migration(migrations.Migration): diff --git a/mayan/apps/tags/serializers.py b/mayan/apps/tags/serializers.py index 439a500225..674c97a383 100644 --- a/mayan/apps/tags/serializers.py +++ b/mayan/apps/tags/serializers.py @@ -15,14 +15,18 @@ from .permissions import permission_tag_attach class TagSerializer(serializers.HyperlinkedModelSerializer): - documents = serializers.HyperlinkedIdentityField(view_name='rest_api:tag-document-list') + documents = serializers.HyperlinkedIdentityField( + view_name='rest_api:tag-document-list' + ) documents_count = serializers.SerializerMethodField() class Meta: extra_kwargs = { 'url': {'view_name': 'rest_api:tag-detail'}, } - fields = ('color', 'documents', 'documents_count', 'id', 'label', 'url') + fields = ( + 'color', 'documents', 'documents_count', 'id', 'label', 'url' + ) model = Tag def get_documents_count(self, instance): @@ -30,14 +34,18 @@ class TagSerializer(serializers.HyperlinkedModelSerializer): class NewDocumentTagSerializer(serializers.Serializer): - tag = serializers.IntegerField(help_text=_('Primary key of the tag to be added.')) + tag = serializers.IntegerField( + help_text=_('Primary key of the tag to be added.') + ) def create(self, validated_data): try: tag = Tag.objects.get(pk=validated_data['tag']) try: - Permission.check_permissions(self.context['request'].user, (permission_tag_attach,)) + Permission.check_permissions( + self.context['request'].user, (permission_tag_attach,) + ) except PermissionDenied: AccessControlList.objects.check_access( permission_tag_attach, self.context['request'], tag diff --git a/setup.py b/setup.py index c17f683137..c17c2b6185 100644 --- a/setup.py +++ b/setup.py @@ -49,7 +49,9 @@ def find_packages(directory): if '__init__.py' in filenames: packages.append('.'.join(fullsplit(dirpath))) elif filenames: - data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames]]) + data_files.append( + [dirpath, [os.path.join(dirpath, f) for f in filenames]] + ) return packages