Minor fixes & pylint appeasements.

This commit is contained in:
voussoir 2018-02-16 21:28:36 -08:00
parent e5a316ff9c
commit 1c1e7f158f
11 changed files with 44 additions and 16 deletions

View file

@ -1,3 +1,7 @@
'''
This file provides data and objects that do not change throughout the runtime.
'''
import converter
import logging
import string

View file

@ -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)

View file

@ -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

View file

@ -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 = {

View file

@ -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:

View file

@ -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

View file

@ -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.

View file

@ -48,7 +48,7 @@
<a href="{{bookmark.url}}"
class="bookmark_title"
data-editor-id="title"
data-editor-placeholer="title"
data-editor-placeholder="title"
data-editor-empty-text="{{bookmark.id}}">
{%- if bookmark.title -%}
{{bookmark.title}}

View file

@ -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);
}

View file

@ -162,8 +162,8 @@ form
{% if search_kwargs[key] %}
{% for tagname in search_kwargs[key] %}
<li class="search_builder_{{tagtype}}_inputted">
<span class="tag_object">{{tagname}}</span><!--
--><button class="remove_tag_button red_button"
<span class="tag_object">{{tagname}}</span>{{-''-}}
<button class="remove_tag_button red_button"
onclick="remove_searchtag(this, '{{tagname}}', inputted_{{tagtype}});"></button>
</li>
{% endfor %}
@ -252,11 +252,11 @@ form
{% do limit_options.sort() %}
{% endif %}
{% for limit_option in limit_options %}
<option
value="{{limit_option}}"
{{"selected" if search_kwargs['limit'] == limit_option else ""}}
<option{{-' '-}}
value="{{limit_option}}"{{-''-}}
{{-" selected" if search_kwargs['limit'] == limit_option else ""-}}
>
{{limit_option}} items
{{- limit_option }} items{{-''-}}
</option>
{% endfor %}
</select>
@ -275,14 +275,14 @@ form
<span>Tags on this page (click to join query):</span>
<ul>
{% for tag in total_tags %}
<li>{{tag_object.tag_object(
<li>{{-tag_object.tag_object(
tag,
extra_classes="tags_on_this_page",
link='void',
qualified_name=False,
with_alt_qualified_name=True,
with_alt_description=True,
)}}</li>
)-}}</li>
{% endfor %}
</ul>
{% endif %}

View file

@ -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") %}