From 1c1e7f158faa41b06906a716cae78177a4dbc785 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Fri, 16 Feb 2018 21:28:36 -0800 Subject: [PATCH] Minor fixes & pylint appeasements. --- etiquette/constants.py | 4 ++++ etiquette/exceptions.py | 1 + etiquette/helpers.py | 5 +++++ etiquette/jsonify.py | 6 ++++-- etiquette/objects.py | 11 ++++++++--- etiquette/searchhelpers.py | 6 ++++++ etiquette/tag_export.py | 5 +++++ .../etiquette_flask/templates/bookmarks.html | 2 +- frontends/etiquette_flask/templates/photo.html | 2 +- frontends/etiquette_flask/templates/search.html | 16 ++++++++-------- .../etiquette_flask/templates/tag_object.html | 2 +- 11 files changed, 44 insertions(+), 16 deletions(-) diff --git a/etiquette/constants.py b/etiquette/constants.py index 95ce0f6..5157d48 100644 --- a/etiquette/constants.py +++ b/etiquette/constants.py @@ -1,3 +1,7 @@ +''' +This file provides data and objects that do not change throughout the runtime. +''' + import converter import logging import string diff --git a/etiquette/exceptions.py b/etiquette/exceptions.py index 55a5e40..9f71af6 100644 --- a/etiquette/exceptions.py +++ b/etiquette/exceptions.py @@ -35,6 +35,7 @@ class EtiquetteException(Exception, metaclass=ErrorTypeAdder): ''' error_message = '' def __init__(self, *args, **kwargs): + super().__init__() self.given_args = args self.given_kwargs = kwargs self.error_message = self.error_message.format(*args, **kwargs) diff --git a/etiquette/helpers.py b/etiquette/helpers.py index cc3fe2e..ce0aeed 100644 --- a/etiquette/helpers.py +++ b/etiquette/helpers.py @@ -1,3 +1,8 @@ +''' +This file provides functions which are used in various places throughout the +codebase but don't deserve to be methods of any class. +''' + import datetime import math import mimetypes diff --git a/etiquette/jsonify.py b/etiquette/jsonify.py index 500d4d8..c7973d6 100644 --- a/etiquette/jsonify.py +++ b/etiquette/jsonify.py @@ -1,5 +1,7 @@ -import json - +''' +This file provides functions that convert the Etiquette objects into +dictionaries suitable for JSON serializing. +''' def album(a, minimal=False): j = { diff --git a/etiquette/objects.py b/etiquette/objects.py index 9b26afb..719dc11 100644 --- a/etiquette/objects.py +++ b/etiquette/objects.py @@ -1,3 +1,8 @@ +''' +This file provides the data objects that should not be instantiated directly, +but are returned by the PDB accesses. +''' + import os import PIL.Image import traceback @@ -623,7 +628,7 @@ class Photo(ObjectBase): 'id': self.id, 'tagged_at': helpers.now(), } - self.photodb.sql_update(table='photos', data=data, where_key='id', commit=False) + self.photodb.sql_update(table='photos', pairs=data, where_key='id', commit=False) if commit: self.photodb.log.debug('Committing - add photo tag') @@ -859,7 +864,7 @@ class Photo(ObjectBase): self.duration = probe.format.duration or probe.video.duration self.width = probe.video.video_width self.height = probe.video.video_height - except: + except Exception: traceback.print_exc() elif self.simple_mimetype == 'audio' and constants.ffmpeg: @@ -867,7 +872,7 @@ class Photo(ObjectBase): probe = constants.ffmpeg.probe(self.real_filepath) if probe and probe.audio: self.duration = probe.audio.duration - except: + except Exception: traceback.print_exc() if self.width and self.height: diff --git a/etiquette/searchhelpers.py b/etiquette/searchhelpers.py index ac384fd..3dbcb74 100644 --- a/etiquette/searchhelpers.py +++ b/etiquette/searchhelpers.py @@ -1,3 +1,9 @@ +''' +This function provides helper functions used to normalize the arguments that +go into search queries. Mainly converting the strings given by the user +into proper data types. +''' + from . import constants from . import exceptions from . import helpers diff --git a/etiquette/tag_export.py b/etiquette/tag_export.py index f79c85f..d75ca16 100644 --- a/etiquette/tag_export.py +++ b/etiquette/tag_export.py @@ -1,3 +1,8 @@ +''' +This file provides a variety of functions for exporting a PDB's tags into other +formats. Strings, dicts, etc. +''' + def easybake(tags): ''' A string where every line is the qualified name of a tag or its synonyms. diff --git a/frontends/etiquette_flask/templates/bookmarks.html b/frontends/etiquette_flask/templates/bookmarks.html index 02cd2ca..836b8d4 100644 --- a/frontends/etiquette_flask/templates/bookmarks.html +++ b/frontends/etiquette_flask/templates/bookmarks.html @@ -48,7 +48,7 @@ {%- if bookmark.title -%} {{bookmark.title}} diff --git a/frontends/etiquette_flask/templates/photo.html b/frontends/etiquette_flask/templates/photo.html index 02dee4e..eb4f9c9 100644 --- a/frontends/etiquette_flask/templates/photo.html +++ b/frontends/etiquette_flask/templates/photo.html @@ -311,7 +311,7 @@ function refresh_metadata(photoid) { var url= "/photo/" + photoid + "/refresh_metadata"; var data = new FormData(); - callback = function(){location.reload();}; + var callback = function(){location.reload();}; post(url, data, callback); } diff --git a/frontends/etiquette_flask/templates/search.html b/frontends/etiquette_flask/templates/search.html index ba55865..dd33030 100644 --- a/frontends/etiquette_flask/templates/search.html +++ b/frontends/etiquette_flask/templates/search.html @@ -162,8 +162,8 @@ form {% if search_kwargs[key] %} {% for tagname in search_kwargs[key] %}
  • - {{tagname}}
  • {% endfor %} @@ -252,11 +252,11 @@ form {% do limit_options.sort() %} {% endif %} {% for limit_option in limit_options %} - {% endfor %} @@ -275,14 +275,14 @@ form Tags on this page (click to join query): {% endif %} diff --git a/frontends/etiquette_flask/templates/tag_object.html b/frontends/etiquette_flask/templates/tag_object.html index 175746f..4c32a5a 100644 --- a/frontends/etiquette_flask/templates/tag_object.html +++ b/frontends/etiquette_flask/templates/tag_object.html @@ -55,7 +55,7 @@ {{' '}}class="tag_object {{extra_classes}}" -{% set altlines=[] %} +{%- set altlines=[] -%} {% if with_alt_qualified_name %}{% do altlines.append(tag.qualified_name()) %}{% endif %} {% if with_alt_description and tag.description != "" %}{% do altlines.append(tag.description) %}{% endif %} {% set altlines=altlines|join("\n") %}