From 1d76b4511bae0cd647c31596442b92621d01b5ab Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Wed, 21 Mar 2018 11:03:58 -0700 Subject: [PATCH] Let PDB.get_tag convert normalization errors to NoSuch. Instead of having to account for them on the other end, since they don't care about that stuff anyway. --- etiquette/photodb.py | 6 +++++- etiquette/searchhelpers.py | 7 +------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/etiquette/photodb.py b/etiquette/photodb.py index e2c2acf..570cc4c 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -831,7 +831,11 @@ class PDBTagMixin: tagname = tagname.strip('.+') tagname = tagname.split('.')[-1].split('+')[0] - tagname = self.normalize_tagname(tagname) + + try: + tagname = self.normalize_tagname(tagname) + except (exceptions.TagTooShort, exceptions.TagTooLong): + raise exceptions.NoSuchTag(tagname) cur = self.sql.cursor() while True: diff --git a/etiquette/searchhelpers.py b/etiquette/searchhelpers.py index 088eed5..6db8c2a 100644 --- a/etiquette/searchhelpers.py +++ b/etiquette/searchhelpers.py @@ -423,12 +423,7 @@ def normalize_tag_mmf(tags, photodb, warning_bag=None): try: tag = photodb.get_tag(name=tag) - exc = None - except exceptions.NoSuchTag as e: - exc = e - except (exceptions.TagTooShort, exceptions.TagTooLong) as e: - exc = exceptions.NoSuchTag(tag) - if exc is not None: + except exceptions.NoSuchTag as exc: if warning_bag: warning_bag.add(exc.error_message) continue