PEP8 cleanups
This commit is contained in:
@@ -45,7 +45,7 @@ class ACLsApp(MayanAppConfig):
|
||||
'acls:acl_class_multiple_grant',
|
||||
'acls:acl_class_multiple_revoke'
|
||||
],
|
||||
)
|
||||
)
|
||||
menu_setup.bind_links(links=[link_acl_setup_valid_classes])
|
||||
menu_sidebar.bind_links(links=[link_acl_holder_new], sources=[AccessObject])
|
||||
|
||||
|
||||
@@ -13,10 +13,12 @@ class EmailAuthenticationForm(forms.Form):
|
||||
"""
|
||||
A form to use email address authentication
|
||||
"""
|
||||
email = forms.CharField(label=_('Email'), max_length=254,
|
||||
widget=EmailInput()
|
||||
email = forms.CharField(
|
||||
label=_('Email'), max_length=254, widget=EmailInput()
|
||||
)
|
||||
password = forms.CharField(
|
||||
label=_('Password'), widget=forms.PasswordInput
|
||||
)
|
||||
password = forms.CharField(label=_('Password'), widget=forms.PasswordInput)
|
||||
|
||||
error_messages = {
|
||||
'invalid_login': _('Please enter a correct email and password. '
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import logging
|
||||
import tempfile
|
||||
|
||||
from django import apps
|
||||
from django.conf import settings
|
||||
from django.conf.urls import include, patterns, url
|
||||
from django.conf.urls import include, url
|
||||
from django.contrib.auth.signals import user_logged_in
|
||||
from django.db.models.signals import post_migrate, post_save
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
@@ -23,8 +22,6 @@ from .menus import (
|
||||
menu_facet, menu_main, menu_secondary, menu_setup, menu_tools
|
||||
)
|
||||
from .models import AnonymousUserSingleton
|
||||
from .settings import setting_temporary_directory
|
||||
from .utils import validate_path
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -40,10 +37,9 @@ class MayanAppConfig(apps.AppConfig):
|
||||
def ready(self):
|
||||
from mayan.urls import urlpatterns
|
||||
|
||||
|
||||
if self.app_url:
|
||||
top_url = '{}/'.format(self.app_url)
|
||||
elif not self.app_url is None:
|
||||
elif self.app_url is not None:
|
||||
top_url = ''
|
||||
else:
|
||||
top_url = '{}/'.format(self.name)
|
||||
@@ -77,7 +73,3 @@ class CommonApp(MayanAppConfig):
|
||||
post_migrate.connect(create_anonymous_user, dispatch_uid='create_anonymous_user', sender=self)
|
||||
user_logged_in.connect(user_locale_profile_session_config, dispatch_uid='user_locale_profile_session_config', sender=settings.AUTH_USER_MODEL)
|
||||
post_save.connect(user_locale_profile_create, dispatch_uid='user_locale_profile_create', sender=settings.AUTH_USER_MODEL)
|
||||
|
||||
# TODO: Create temp directory and update setting if /tmp not found/writable or value == None
|
||||
#if (not validate_path(setting_temporary_directory.value)) or (not setting_temporary_directory.value):
|
||||
# setattr(common_settings, 'setting_temporary_directory.value', tempfile.mkdtemp())
|
||||
|
||||
@@ -7,7 +7,6 @@ import types
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.utils.datastructures import MultiValueDict
|
||||
from django.utils.http import urlquote as django_urlquote
|
||||
from django.utils.http import urlencode as django_urlencode
|
||||
|
||||
@@ -73,6 +73,7 @@ CONVERTER_OFFICE_FILE_MIMETYPES = (
|
||||
'text/rtf',
|
||||
)
|
||||
|
||||
|
||||
class ConverterBase(object):
|
||||
@staticmethod
|
||||
def soffice(file_object):
|
||||
|
||||
@@ -2,7 +2,6 @@ from __future__ import unicode_literals
|
||||
|
||||
import shutil
|
||||
|
||||
from django.core.files.base import File
|
||||
from django.test import TestCase
|
||||
|
||||
from .api import GPG, Key
|
||||
|
||||
@@ -15,7 +15,6 @@ from common.utils import encapsulate
|
||||
from permissions.models import Permission
|
||||
|
||||
from .api import Key
|
||||
from .exceptions import KeyImportError
|
||||
from .forms import KeySearchForm
|
||||
from .permissions import (
|
||||
PERMISSION_KEY_DELETE, PERMISSION_KEY_RECEIVE, PERMISSION_KEY_VIEW,
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import tempfile
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from actstream import registry
|
||||
@@ -15,7 +13,7 @@ from common import (
|
||||
from common.api import register_maintenance_links
|
||||
from common.classes import ModelAttribute
|
||||
from common.signals import post_initial_setup
|
||||
from common.utils import encapsulate, validate_path
|
||||
from common.utils import encapsulate
|
||||
from converter.links import link_transformation_list
|
||||
from converter.permissions import (
|
||||
PERMISSION_TRANSFORMATION_CREATE,
|
||||
@@ -74,10 +72,6 @@ class DocumentsApp(MayanAppConfig):
|
||||
def ready(self):
|
||||
super(DocumentsApp, self).ready()
|
||||
|
||||
# TODO: validate cache_path or create new
|
||||
#if (not validate_path(document_settings.CACHE_PATH)) or (not document_settings.CACHE_PATH):
|
||||
# setattr(document_settings, 'CACHE_PATH', tempfile.mkdtemp())
|
||||
|
||||
APIEndPoint('documents')
|
||||
|
||||
MissingItem(label=_('Create a document type'), description=_('Every uploaded document must be assigned a document type, it is the basic way Mayan EDMS categorizes documents.'), condition=lambda: not DocumentType.objects.exists(), view='documents:document_type_list')
|
||||
|
||||
@@ -410,8 +410,6 @@ class DocumentVersion(models.Model):
|
||||
logger.debug('Intermidiate file "%s" found.', cache_filename)
|
||||
|
||||
return open(cache_filename)
|
||||
#converter = converter_class(file_object=open(cache_filename))
|
||||
#converter.seek(0)
|
||||
else:
|
||||
logger.debug('Intermidiate file "%s" not found.', cache_filename)
|
||||
|
||||
@@ -539,7 +537,7 @@ class DocumentPage(models.Model):
|
||||
file_object.write(page_image.getvalue())
|
||||
except Exception as exception:
|
||||
# Cleanup in case of error
|
||||
logger.error('Error creating page cache file "%s".', cache_filename)
|
||||
logger.error('Error creating page cache file "%s"; %s', cache_filename, exception)
|
||||
fs_cleanup(cache_filename)
|
||||
raise
|
||||
|
||||
|
||||
@@ -21,8 +21,7 @@ from common.utils import encapsulate, pretty_size
|
||||
from common.views import ParentChildListView, SingleObjectListView
|
||||
from common.widgets import two_state_template
|
||||
from converter.literals import (
|
||||
DEFAULT_FILE_FORMAT_MIMETYPE, DEFAULT_PAGE_NUMBER, DEFAULT_ROTATION,
|
||||
DEFAULT_ZOOM_LEVEL
|
||||
DEFAULT_PAGE_NUMBER, DEFAULT_ROTATION, DEFAULT_ZOOM_LEVEL
|
||||
)
|
||||
from converter.models import Transformation
|
||||
from converter.permissions import PERMISSION_TRANSFORMATION_DELETE
|
||||
|
||||
@@ -17,5 +17,3 @@ class EventType(models.Model):
|
||||
class Meta:
|
||||
verbose_name = _('Event type')
|
||||
verbose_name_plural = _('Event types')
|
||||
|
||||
|
||||
|
||||
@@ -236,18 +236,6 @@ class Link(object):
|
||||
return resolved_link
|
||||
|
||||
|
||||
class ModelListColumn(object):
|
||||
_model_list_columns = {}
|
||||
|
||||
@classmethod
|
||||
def get_model(cls, model):
|
||||
return cls._model_list_columns.get(model)
|
||||
|
||||
def __init__(self, model, name, attribute):
|
||||
self.__class__._model_list_columns.setdefault(model, [])
|
||||
self.__class__._model_list_columns[model].extend(columns)
|
||||
|
||||
|
||||
class SourceColumn(object):
|
||||
_registry = {}
|
||||
|
||||
|
||||
@@ -8,20 +8,7 @@ class MultiItemForm(forms.Form):
|
||||
def __init__(self, *args, **kwargs):
|
||||
actions = kwargs.pop('actions', [])
|
||||
super(MultiItemForm, self).__init__(*args, **kwargs)
|
||||
choices = []
|
||||
group = []
|
||||
|
||||
for action in actions:
|
||||
if not action[0]:
|
||||
if group:
|
||||
choices.append((link_spacer['text'], group))
|
||||
group = []
|
||||
else:
|
||||
group.append(action)
|
||||
|
||||
if choices:
|
||||
self.fields['action'].choices = choices
|
||||
else:
|
||||
self.fields['action'].choices = group
|
||||
self.fields['action'].choices = actions
|
||||
|
||||
action = forms.ChoiceField(label=_('Actions'), required=False)
|
||||
|
||||
@@ -9,12 +9,8 @@ import sh
|
||||
from common.settings import setting_temporary_directory
|
||||
|
||||
from .exceptions import UnpaperError
|
||||
from .literals import (
|
||||
DEFAULT_OCR_FILE_EXTENSION, DEFAULT_OCR_FILE_FORMAT, UNPAPER_FILE_FORMAT
|
||||
)
|
||||
from .parsers import parse_document_page
|
||||
from .parsers.exceptions import ParserError, ParserUnknownFile
|
||||
from .runtime import ocr_backend
|
||||
from .settings import UNPAPER_PATH
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -28,10 +28,7 @@ from .links import (
|
||||
link_entry_re_queue, link_entry_re_queue_multiple
|
||||
)
|
||||
from .models import DocumentVersionOCRError
|
||||
from .permissions import (
|
||||
PERMISSION_OCR_DOCUMENT, PERMISSION_OCR_CONTENT_VIEW,
|
||||
PERMISSION_DOCUMENT_TYPE_OCR_SETUP
|
||||
)
|
||||
from .permissions import PERMISSION_OCR_DOCUMENT, PERMISSION_OCR_CONTENT_VIEW
|
||||
from .settings import setting_pdftotext_path, setting_tesseract_path, setting_unpaper_path
|
||||
from .tasks import task_do_ocr
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
|
||||
@@ -4,9 +4,6 @@ import logging
|
||||
|
||||
from converter import converter_class
|
||||
|
||||
from .literals import (
|
||||
DEFAULT_OCR_FILE_EXTENSION, DEFAULT_OCR_FILE_FORMAT, UNPAPER_FILE_FORMAT
|
||||
)
|
||||
from .models import DocumentPageContent
|
||||
from .parsers import parse_document_page
|
||||
from .parsers.exceptions import ParserError, ParserUnknownFile
|
||||
@@ -25,7 +22,7 @@ class OCRBackendBase(object):
|
||||
image = page.get_image()
|
||||
logger.info('Processing page: %d of document version: %s', page.page_number, document_version)
|
||||
document_page_content, created = DocumentPageContent.objects.get_or_create(document_page=page)
|
||||
result = self.execute(file_object=image, language=language)
|
||||
result = self.execute(file_object=image, language=language)
|
||||
document_page_content.content = self.execute(file_object=image, language=language)
|
||||
document_page_content.save()
|
||||
image.close()
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
DEFAULT_OCR_FILE_FORMAT = 'tiff'
|
||||
DEFAULT_OCR_FILE_EXTENSION = 'tif'
|
||||
LOCK_EXPIRE = 60 * 10 # Adjust to worst case scenario
|
||||
UNPAPER_FILE_FORMAT = 'ppm'
|
||||
|
||||
@@ -228,8 +228,8 @@ class UserGroupsView(AssignRemoveView):
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
Permission.objects.check_permissions(request.user, [PERMISSION_USER_EDIT])
|
||||
self.user = get_object_or_404(User, pk=self.kwargs['user_id'])
|
||||
self.left_list_title=_('Non groups of user: %s') % self.user
|
||||
self.right_list_title=_('Groups of user: %s') % self.user
|
||||
self.left_list_title = _('Non groups of user: %s') % self.user
|
||||
self.right_list_title = _('Groups of user: %s') % self.user
|
||||
|
||||
return super(UserGroupsView, self).dispatch(request, *args, **kwargs)
|
||||
|
||||
|
||||
@@ -34,22 +34,22 @@ LOGGING = {
|
||||
},
|
||||
},
|
||||
'handlers': {
|
||||
'console':{
|
||||
'level':'DEBUG',
|
||||
'class':'logging.StreamHandler',
|
||||
'console': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.StreamHandler',
|
||||
'formatter': 'intermediate'
|
||||
}
|
||||
},
|
||||
'loggers': {
|
||||
'documents': {
|
||||
'handlers':['console'],
|
||||
'handlers': ['console'],
|
||||
'propagate': True,
|
||||
'level':'DEBUG',
|
||||
'level': 'DEBUG',
|
||||
},
|
||||
'common': {
|
||||
'handlers':['console'],
|
||||
'handlers': ['console'],
|
||||
'propagate': True,
|
||||
'level':'DEBUG',
|
||||
'level': 'DEBUG',
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user