Remove unnecessary warning_bag code from normalize_tagname
This commit is contained in:
parent
e413e996d9
commit
c04b5a6db0
3 changed files with 12 additions and 18 deletions
|
@ -928,7 +928,7 @@ class PDBTagMixin:
|
|||
tag = objects.Tag(self, [tagid, tagname])
|
||||
return tag
|
||||
|
||||
def normalize_tagname(self, tagname, warning_bag=None):
|
||||
def normalize_tagname(self, tagname):
|
||||
'''
|
||||
Tag names can only consist of characters defined in the config.
|
||||
The given tagname is lowercased, gets its spaces and hyphens
|
||||
|
@ -943,20 +943,10 @@ class PDBTagMixin:
|
|||
tagname = ''.join(tagname)
|
||||
|
||||
if len(tagname) < self.config['min_tag_name_length']:
|
||||
exc = exceptions.TagTooShort(original_tagname)
|
||||
if warning_bag is not None:
|
||||
warning_bag.add(exc.error_message)
|
||||
return None
|
||||
else:
|
||||
raise exc
|
||||
raise exceptions.TagTooShort(original_tagname)
|
||||
|
||||
elif len(tagname) > self.config['max_tag_name_length']:
|
||||
exc = exceptions.TagTooLong(tagname)
|
||||
if warning_bag is not None:
|
||||
warning_bag.add(exc.error_message)
|
||||
return None
|
||||
else:
|
||||
raise exc
|
||||
raise exceptions.TagTooLong(tagname)
|
||||
|
||||
else:
|
||||
return tagname
|
||||
|
@ -1280,7 +1270,7 @@ class PhotoDB(PDBAlbumMixin, PDBBookmarkMixin, PDBPhotoMixin, PDBTagMixin, PDBUs
|
|||
'''
|
||||
output_notes = []
|
||||
def create_or_get(name):
|
||||
print('cog', name)
|
||||
#print('cog', name)
|
||||
try:
|
||||
item = self.get_tag(name)
|
||||
note = ('existing_tag', item.qualified_name())
|
||||
|
|
|
@ -309,12 +309,17 @@ 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:
|
||||
if warning_bag:
|
||||
warning_bag.add(e.error_message)
|
||||
warning_bag.add(exc.error_message)
|
||||
continue
|
||||
else:
|
||||
raise
|
||||
raise exc
|
||||
tagset.add(tag)
|
||||
|
||||
if len(tagset) == 0:
|
||||
|
|
|
@ -63,7 +63,6 @@ def delete_tag(tag):
|
|||
|
||||
def delete_synonym(synonym):
|
||||
synonym = synonym.split('+')[-1].split('.')[-1]
|
||||
synonym = P.normalize_tagname(synonym)
|
||||
|
||||
try:
|
||||
master_tag = P.get_tag(synonym)
|
||||
|
@ -708,7 +707,7 @@ def post_tag_create_delete_core(tagname, function):
|
|||
'error_message': e.error_message,
|
||||
}
|
||||
status = 400
|
||||
print(response)
|
||||
#print(response)
|
||||
|
||||
return jsonify.make_json_response(response, status=status)
|
||||
|
||||
|
|
Loading…
Reference in a new issue