From d66dc532158a12326e3d3b8a903c7cdd8629b9cd Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Tue, 1 Jan 2019 18:08:47 -0800 Subject: [PATCH] Require voussoirkit 0.0.28 for sqlhelpers.listify. Instead of defining that within etiquette. --- etiquette/helpers.py | 9 --------- etiquette/objects.py | 9 +++++---- etiquette/photodb.py | 2 +- etiquette/searchhelpers.py | 3 ++- requirements.txt | 2 +- 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/etiquette/helpers.py b/etiquette/helpers.py index 0fc2989..1725559 100644 --- a/etiquette/helpers.py +++ b/etiquette/helpers.py @@ -482,15 +482,6 @@ def split_easybake_string(ebstring): tagname = tagname.strip('.') return (tagname, synonym, rename_to) -def sql_listify(items): - ''' - Given a list of strings, return a string in the form of an SQL list. - - ['hi', 'ho', 'hey'] -> '("hi", "ho", "hey")' - ''' - items = ', '.join(f'"{item}"' for item in items) - return '(%s)' % items - def truthystring(s): ''' If s is already a boolean, int, or None, return a boolean or None. diff --git a/etiquette/objects.py b/etiquette/objects.py index 6d5001d..90837c2 100644 --- a/etiquette/objects.py +++ b/etiquette/objects.py @@ -10,6 +10,7 @@ import traceback from voussoirkit import bytestring from voussoirkit import pathclass from voussoirkit import spinal +from voussoirkit import sqlhelpers from . import constants from . import decorators @@ -517,7 +518,7 @@ class Album(ObjectBase, GroupableMixin): else: albumids = [self.id] - albumids = helpers.sql_listify(albumids) + albumids = sqlhelpers.listify(albumids) query = query.format(albumids=albumids) total = self.photodb.sql_select_one(query)[0] return total @@ -538,7 +539,7 @@ class Album(ObjectBase, GroupableMixin): else: albumids = [self.id] - albumids = helpers.sql_listify(albumids) + albumids = sqlhelpers.listify(albumids) query = query.format(albumids=albumids) total = self.photodb.sql_select_one(query)[0] return total @@ -886,7 +887,7 @@ class Photo(ObjectBase): tag_options = [tag] tag_by_id = {t.id: t for t in tag_options} - tag_option_ids = helpers.sql_listify(tag_by_id) + tag_option_ids = sqlhelpers.listify(tag_by_id) rel_row = self.photodb.sql_select_one( f'SELECT tagid FROM photo_tag_rel WHERE photoid == ? AND tagid IN {tag_option_ids}', [self.id] @@ -1293,7 +1294,7 @@ class Tag(ObjectBase, GroupableMixin): UPDATE photo_tag_rel SET tagid = ? WHERE tagid == ? - AND photoid IN {helpers.sql_listify(replace_photoids)} + AND photoid IN {sqlhelpers.listify(replace_photoids)} ''' bindings = [mastertag.id, self.id] self.photodb.sql_execute(query, bindings) diff --git a/etiquette/photodb.py b/etiquette/photodb.py index b249985..d956340 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -566,7 +566,7 @@ class PDBPhotoMixin: if author: author_ids = [user.id for user in author] - wheres.append('author_id IN %s' % helpers.sql_listify(author_ids)) + wheres.append(f'author_id IN {sqlhelpers.listify(author_ids)}') if extension: if '*' in extension: diff --git a/etiquette/searchhelpers.py b/etiquette/searchhelpers.py index c6c918f..092227b 100644 --- a/etiquette/searchhelpers.py +++ b/etiquette/searchhelpers.py @@ -9,6 +9,7 @@ from . import helpers from . import objects from voussoirkit import expressionmatch +from voussoirkit import sqlhelpers def expand_mmf(tag_musts, tag_mays, tag_forbids): @@ -389,7 +390,7 @@ def photo_tag_rel_exist_clauses(tag_musts, tag_mays, tag_forbids): clauses.append( ('NOT EXISTS', tag_forbids) ) clauses = [ - (operator, helpers.sql_listify(tag.id for tag in tagset)) + (operator, sqlhelpers.listify(tag.id for tag in tagset)) for (operator, tagset) in clauses ] clauses = [ diff --git a/requirements.txt b/requirements.txt index 0a76cd7..f48243d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,4 +15,4 @@ git+https://github.com/senko/python-video-converter.git zipstream # My own variety toolkit. -voussoirkit>=0.0.25 +voussoirkit>=0.0.28