From 091dc82f1e02a9ad4e887f57042615925eca0a4c Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 6 May 2017 18:37:02 -0700 Subject: [PATCH] Catch expressionmatch.NoTokens for filename search --- etiquette/photodb.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/etiquette/photodb.py b/etiquette/photodb.py index 009e9fa..a4320d4 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -743,8 +743,13 @@ class PDBPhotoMixin: tag_match_function = searchhelpers.tag_expression_matcher_builder(frozen_children) if filename: - filename_tree = expressionmatch.ExpressionTree.parse(filename) - filename_tree.map(lambda x: x.lower()) + try: + filename_tree = expressionmatch.ExpressionTree.parse(filename) + filename_tree.map(lambda x: x.lower()) + except expressionmatch.NoTokens: + filename_tree = None + else: + filename_tree = None if give_back_parameters: parameters = { @@ -820,7 +825,7 @@ class PDBPhotoMixin: #print('Failed author') continue - if filename and not filename_tree.evaluate(photo.basename.lower()): + if filename_tree and not filename_tree.evaluate(photo.basename.lower()): #print('Failed filename') continue