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