diff --git a/apps/common/templatetags/subtemplates_tags.py b/apps/common/templatetags/subtemplates_tags.py index 157a7f0c89..d759df4bbb 100644 --- a/apps/common/templatetags/subtemplates_tags.py +++ b/apps/common/templatetags/subtemplates_tags.py @@ -19,11 +19,11 @@ class RenderSubtemplateNode(Node): new_context = Context(context) new_context.update(Context(template_context, autoescape=context.autoescape)) - + csrf_token = context.get('csrf_token', None) if csrf_token is not None: new_context['csrf_token'] = csrf_token - + context[self.var_name] = get_template(template_name).render(new_context) return '' @@ -40,12 +40,12 @@ def render_subtemplate(parser, token): if not m: raise TemplateSyntaxError('%r tag had invalid arguments' % tag_name) template_name, template_context, var_name = m.groups() - + if (template_name[0] == template_name[-1] and template_name[0] in ('"', "'")): raise TemplateSyntaxError('%r tag\'s template name argument should not be in quotes' % tag_name) if (template_context[0] == template_context[-1] and template_context[0] in ('"', "'")): raise TemplateSyntaxError('%r tag\'s template context argument should not be in quotes' % tag_name) - + return RenderSubtemplateNode(template_name, template_context, var_name) #format_string[1:-1] diff --git a/apps/common/utils.py b/apps/common/utils.py index 4853e93e4d..403ab64d92 100644 --- a/apps/common/utils.py +++ b/apps/common/utils.py @@ -94,7 +94,7 @@ def pretty_size(size, suffixes=None): def pretty_size_10(size): return pretty_size( - size, + size, suffixes=[ (u'B', 1000L), (u'K', 1000000L), (u'M', 1000000000L), (u'G', 1000000000000L), (u'T', 1000000000000000L) @@ -302,12 +302,12 @@ def return_type(value): return ','.join(list(value)) else: return value - + # http://stackoverflow.com/questions/4248399/page-range-for-printing-algorithm def parse_range(astr): - result=set() + result = set() for part in astr.split(u','): - x=part.split(u'-') - result.update(range(int(x[0]),int(x[-1])+1)) + x = part.split(u'-') + result.update(range(int(x[0]), int(x[-1]) + 1)) return sorted(result) diff --git a/apps/converter/api.py b/apps/converter/api.py index f05c05f69b..e23a8326c4 100644 --- a/apps/converter/api.py +++ b/apps/converter/api.py @@ -126,9 +126,9 @@ def convert_document(document, *args, **kwargs): document_filepath = create_image_cache_filename(document.checksum, *args, **kwargs) if os.path.exists(document_filepath): return document_filepath - + return convert(document_save_to_temp_dir(document, document.checksum), *args, **kwargs) - + def convert(input_filepath, *args, **kwargs): size = kwargs.get('size') @@ -139,9 +139,9 @@ def convert(input_filepath, *args, **kwargs): page = kwargs.get('page', DEFAULT_PAGE_INDEX_NUMBER) cleanup_files = kwargs.get('cleanup_files', True) quality = kwargs.get('quality', QUALITY_DEFAULT) - + unoconv_output = None - + output_filepath = create_image_cache_filename(input_filepath, *args, **kwargs) if os.path.exists(output_filepath): return output_filepath @@ -190,7 +190,7 @@ def get_document_dimensions(document, *args, **kwargs): return [int(dimension) for dimension in backend.execute_identify(unicode(document_filepath), options).split()] else: return [0, 0] - + def convert_document_for_ocr(document, page=DEFAULT_PAGE_INDEX_NUMBER, file_format=DEFAULT_OCR_FILE_FORMAT): #Extract document file diff --git a/apps/converter/backends/imagemagick.py b/apps/converter/backends/imagemagick.py index a2b99b2c96..b5122cc96a 100644 --- a/apps/converter/backends/imagemagick.py +++ b/apps/converter/backends/imagemagick.py @@ -13,7 +13,7 @@ def execute_identify(input_filepath, arguments=None): command = [] command.append(unicode(IM_IDENTIFY_PATH)) if arguments: - command.extend(arguments) + command.extend(arguments) command.append(unicode(input_filepath)) proc = subprocess.Popen(command, close_fds=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE) diff --git a/apps/main/__init__.py b/apps/main/__init__.py index 2b8325ae86..ffec7d64b1 100644 --- a/apps/main/__init__.py +++ b/apps/main/__init__.py @@ -1,12 +1,7 @@ from django.utils.translation import ugettext_lazy as _ from navigation.api import register_menu - from permissions import role_list - -from documents import document_find_all_duplicates -from filesystem_serving import filesystem_serving_recreate_all_links -from ocr import all_document_ocr_cleanup from user_management import user_list from main.conf.settings import SIDE_BAR_SEARCH @@ -55,7 +50,7 @@ def get_version(): Return the formatted version information """ vers = ["%(major)i.%(minor)i" % __version_info__, ] - + if __version_info__['micro']: vers.append(".%(micro)i" % __version_info__) if __version_info__['releaselevel'] != 'final': diff --git a/apps/main/api.py b/apps/main/api.py index 8f4ec08146..81678000e5 100644 --- a/apps/main/api.py +++ b/apps/main/api.py @@ -1,5 +1,5 @@ from django.core.urlresolvers import reverse -from django.utils.functional import lazy +from django.utils.functional import lazy diagnostics = {} tools = {} @@ -9,7 +9,7 @@ reverse_lazy = lazy(reverse, str) def register_diagnostic(namespace, title, link): namespace_dict = diagnostics.get(namespace, {'title': None, 'links': []}) namespace_dict['title'] = title - link['url'] = link.get('url', reverse(link['view'])) + link['url'] = link.get('url', reverse_lazy(link['view'])) namespace_dict['links'].append(link) diagnostics[namespace] = namespace_dict diff --git a/apps/main/views.py b/apps/main/views.py index 247106315a..cc1c40bebc 100644 --- a/apps/main/views.py +++ b/apps/main/views.py @@ -134,7 +134,7 @@ def tools_menu(request): user_tools[namespace] = { 'title': values['title'] } - user_links = user_tools[namespace].setdefault('links', []) + user_tools[namespace].setdefault('links', []) user_tools[namespace]['links'].append(link) except PermissionDenied: pass diff --git a/apps/navigation/templatetags/navigation_tags.py b/apps/navigation/templatetags/navigation_tags.py index ae66927059..9690daa80e 100644 --- a/apps/navigation/templatetags/navigation_tags.py +++ b/apps/navigation/templatetags/navigation_tags.py @@ -7,8 +7,8 @@ from django.template import TemplateSyntaxError, Library, \ from django.utils.text import unescape_string_literal from django.utils.translation import ugettext as _ -from django.template import TemplateSyntaxError, Library, Context - +from django.template import Context + from navigation.api import object_navigation, multi_object_navigation, \ menu_links as menu_navigation, sidebar_templates from navigation.forms import MultiItemForm @@ -34,14 +34,13 @@ def process_links(links, view_name, url): child_view = 'view' in child_link and child_link['view'] child_url = 'url' in child_link and child_link['url'] if view_name == child_view or url == child_url: - active = True active_item = item new_link.update({ 'first': count == 0, 'url': item_view and reverse(item_view) or item_url or u'#', }) items.append(new_link) - + return items, active_item @@ -151,7 +150,7 @@ def _get_object_navigation_links(context, menu_name=None, links_dict=object_navi obj = Variable(object_name).resolve(context) except VariableDoesNotExist: obj = None - + try: links = links_dict[menu_name][current_view]['links'] for link in resolve_links(context, links, current_view, current_path): @@ -267,8 +266,8 @@ class EvaluateLinkNone(Node): def render(self, context): condition = Variable(self.condition).resolve(context) if condition: - context[self.var_name] = condition(Context(context)) - return u'' + context[self.var_name] = condition(Context(context)) + return u'' else: context[self.var_name] = True return u'' diff --git a/apps/ocr/__init__.py b/apps/ocr/__init__.py index 36d8ca4067..51b7ca714a 100644 --- a/apps/ocr/__init__.py +++ b/apps/ocr/__init__.py @@ -2,7 +2,6 @@ from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext from django.db.utils import DatabaseError from django.db.models.signals import post_save -from django.core.urlresolvers import reverse from navigation.api import register_links, register_menu, register_multi_item_links from permissions.api import register_permissions @@ -11,7 +10,6 @@ from main.api import register_tool from ocr.conf.settings import AUTOMATIC_OCR from ocr.models import DocumentQueue -from ocr.urls import urlpatterns #Permissions PERMISSION_OCR_DOCUMENT = 'ocr_document' diff --git a/apps/ocr/api.py b/apps/ocr/api.py index 61040e7aba..d0e4668c51 100644 --- a/apps/ocr/api.py +++ b/apps/ocr/api.py @@ -121,7 +121,7 @@ def ocr_cleanup(text): Cleanup the OCR's output passing it thru the selected language's cleanup filter """ - + output = [] for line in text.splitlines(): line = line.strip() diff --git a/apps/ocr/tasks.py b/apps/ocr/tasks.py index 17ecded17a..7449cec525 100644 --- a/apps/ocr/tasks.py +++ b/apps/ocr/tasks.py @@ -17,9 +17,10 @@ from ocr.conf.settings import NODE_CONCURRENT_EXECUTION from ocr.conf.settings import REPLICATION_DELAY from ocr.conf.settings import QUEUE_PROCESSING_INTERVAL -LOCK_EXPIRE = 60 * 5 # Lock expires in 5 minutes +LOCK_EXPIRE = 60 * 5 # Lock expires in 5 minutes local_cache = CacheClass([], {}) + @task def task_process_queue_document(queue_document_id): queue_document = QueueDocument.objects.get(id=queue_document_id) @@ -40,7 +41,7 @@ def reset_orphans(): i = inspect().active() active_tasks = [] orphans = [] - + if i: for host, instances in i.items(): for instance in instances: diff --git a/apps/ocr/views.py b/apps/ocr/views.py index d203f46f62..87026f1d0a 100644 --- a/apps/ocr/views.py +++ b/apps/ocr/views.py @@ -274,7 +274,7 @@ def all_document_ocr_cleanup(request): def display_link(obj): output = [] if hasattr(obj, 'get_absolute_url'): - output.append(u'%(obj)s'% { + output.append(u'%(obj)s' % { 'url': obj.get_absolute_url(), 'obj': obj }) diff --git a/apps/tags/views.py b/apps/tags/views.py index 965c191029..969e11a531 100644 --- a/apps/tags/views.py +++ b/apps/tags/views.py @@ -21,7 +21,7 @@ def tag_remove(request, tag_id, document_id): tag = get_object_or_404(Tag, pk=tag_id) document = get_object_or_404(Document, pk=document_id) - + previous = request.POST.get('previous', request.GET.get('previous', request.META.get('HTTP_REFERER', None))) document.tags.remove(tag) messages.success(request, _(u'Tag "%s" removed successfully.') % tag) diff --git a/apps/tags/widgets.py b/apps/tags/widgets.py index 47e48ff678..fc9350ba92 100644 --- a/apps/tags/widgets.py +++ b/apps/tags/widgets.py @@ -9,7 +9,7 @@ def get_tags_inline_widget(document): tags_template.append(u'
') tags_template.append(u'
%(tag_string)s: %(tag_count)s
' % { 'tag_string': _(u'Tags'), 'tag_count': tag_count}) - + for tag in document.tags.all(): tags_template.append(tag_block_template % (tag.tagproperties_set.get().get_color_code(), tag.name)) @@ -23,7 +23,7 @@ def get_tags_inline_widget_simple(document): tag_count = document.tags.count() if tag_count: tags_template.append(u'
') - + for tag in document.tags.all(): tags_template.append(tag_block_template % (tag.tagproperties_set.get().get_color_code(), tag.name))