Use voussoirkit.stringtools for comma_space_split.
This commit is contained in:
		
							parent
							
								
									98b6d93094
								
							
						
					
					
						commit
						469103e0ac
					
				
					 5 changed files with 19 additions and 25 deletions
				
			
		|  | @ -149,17 +149,6 @@ def checkerboard_image(color_1, color_2, image_size, checker_size): | ||||||
|         offset = not offset |         offset = not offset | ||||||
|     return image |     return image | ||||||
| 
 | 
 | ||||||
| def comma_space_split(s): |  | ||||||
|     ''' |  | ||||||
|     Split the string apart by commas and spaces, discarding all extra |  | ||||||
|     whitespace and blank phrases. |  | ||||||
| 
 |  | ||||||
|     'a b, c,,d' -> ['a', 'b', 'c', 'd'] |  | ||||||
|     ''' |  | ||||||
|     if s is None: |  | ||||||
|         return s |  | ||||||
|     return re.split(r'[ ,]+', s.strip()) |  | ||||||
| 
 |  | ||||||
| def decollide_names(things, namer): | def decollide_names(things, namer): | ||||||
|     ''' |     ''' | ||||||
|     When generating zip files, or otherwise exporting photos to disk, it is |     When generating zip files, or otherwise exporting photos to disk, it is | ||||||
|  |  | ||||||
|  | @ -11,6 +11,7 @@ from . import objects | ||||||
| from voussoirkit import expressionmatch | from voussoirkit import expressionmatch | ||||||
| from voussoirkit import pathclass | from voussoirkit import pathclass | ||||||
| from voussoirkit import sqlhelpers | from voussoirkit import sqlhelpers | ||||||
|  | from voussoirkit import stringtools | ||||||
| 
 | 
 | ||||||
| def expand_mmf(tag_musts, tag_mays, tag_forbids): | def expand_mmf(tag_musts, tag_mays, tag_forbids): | ||||||
|     ''' |     ''' | ||||||
|  | @ -131,7 +132,7 @@ def normalize_author(authors, photodb, warning_bag=None): | ||||||
|         authors = [] |         authors = [] | ||||||
| 
 | 
 | ||||||
|     if isinstance(authors, str): |     if isinstance(authors, str): | ||||||
|         authors = helpers.comma_space_split(authors) |         authors = stringtools.comma_space_split(authors) | ||||||
| 
 | 
 | ||||||
|     users = set() |     users = set() | ||||||
|     for requested_author in authors: |     for requested_author in authors: | ||||||
|  | @ -165,7 +166,7 @@ def normalize_extension(extensions): | ||||||
|         extensions = set() |         extensions = set() | ||||||
| 
 | 
 | ||||||
|     elif isinstance(extensions, str): |     elif isinstance(extensions, str): | ||||||
|         extensions = helpers.comma_space_split(extensions) |         extensions = stringtools.comma_space_split(extensions) | ||||||
| 
 | 
 | ||||||
|     extensions = [e.lower().strip('.').strip() for e in extensions] |     extensions = [e.lower().strip('.').strip() for e in extensions] | ||||||
|     extensions = set(e for e in extensions if e) |     extensions = set(e for e in extensions if e) | ||||||
|  | @ -468,7 +469,7 @@ def normalize_tagset(photodb, tags, warning_bag=None): | ||||||
|         return None |         return None | ||||||
| 
 | 
 | ||||||
|     if isinstance(tags, str): |     if isinstance(tags, str): | ||||||
|         tags = helpers.comma_space_split(tags) |         tags = stringtools.comma_space_split(tags) | ||||||
| 
 | 
 | ||||||
|     tagset = set() |     tagset = set() | ||||||
|     for tag in tags: |     for tag in tags: | ||||||
|  |  | ||||||
|  | @ -3,6 +3,7 @@ import sys | ||||||
| 
 | 
 | ||||||
| from voussoirkit import getpermission | from voussoirkit import getpermission | ||||||
| from voussoirkit import pathclass | from voussoirkit import pathclass | ||||||
|  | from voussoirkit import stringtools | ||||||
| from voussoirkit import vlogging | from voussoirkit import vlogging | ||||||
| 
 | 
 | ||||||
| import etiquette | import etiquette | ||||||
|  | @ -376,8 +377,8 @@ def main(argv): | ||||||
| 
 | 
 | ||||||
|     photo_search_args = p_search.parse_args(photo_search_args) if photo_search_args else None |     photo_search_args = p_search.parse_args(photo_search_args) if photo_search_args else None | ||||||
|     album_search_args = p_search.parse_args(album_search_args) if album_search_args else None |     album_search_args = p_search.parse_args(album_search_args) if album_search_args else None | ||||||
|     photo_id_args = [id for arg in photo_id_args for id in etiquette.helpers.comma_space_split(arg)] |     photo_id_args = [id for arg in photo_id_args for id in stringtools.comma_space_split(arg)] | ||||||
|     album_id_args = [id for arg in album_id_args for id in etiquette.helpers.comma_space_split(arg)] |     album_id_args = [id for arg in album_id_args for id in stringtools.comma_space_split(arg)] | ||||||
| 
 | 
 | ||||||
|     args.photo_search_args = photo_search_args |     args.photo_search_args = photo_search_args | ||||||
|     args.album_search_args = album_search_args |     args.album_search_args = album_search_args | ||||||
|  |  | ||||||
|  | @ -2,6 +2,8 @@ import flask; from flask import request | ||||||
| import time | import time | ||||||
| import urllib.parse | import urllib.parse | ||||||
| 
 | 
 | ||||||
|  | from voussoirkit import stringtools | ||||||
|  | 
 | ||||||
| import etiquette | import etiquette | ||||||
| 
 | 
 | ||||||
| from .. import caching | from .. import caching | ||||||
|  | @ -59,7 +61,7 @@ def get_album_zip(album_id): | ||||||
| def post_album_add_child(album_id): | def post_album_add_child(album_id): | ||||||
|     album = common.P_album(album_id, response_type='json') |     album = common.P_album(album_id, response_type='json') | ||||||
| 
 | 
 | ||||||
|     child_ids = etiquette.helpers.comma_space_split(request.form['child_id']) |     child_ids = stringtools.comma_space_split(request.form['child_id']) | ||||||
|     children = list(common.P_albums(child_ids, response_type='json')) |     children = list(common.P_albums(child_ids, response_type='json')) | ||||||
|     print(children) |     print(children) | ||||||
|     album.add_children(children, commit=True) |     album.add_children(children, commit=True) | ||||||
|  | @ -71,7 +73,7 @@ def post_album_add_child(album_id): | ||||||
| def post_album_remove_child(album_id): | def post_album_remove_child(album_id): | ||||||
|     album = common.P_album(album_id, response_type='json') |     album = common.P_album(album_id, response_type='json') | ||||||
| 
 | 
 | ||||||
|     child_ids = etiquette.helpers.comma_space_split(request.form['child_id']) |     child_ids = stringtools.comma_space_split(request.form['child_id']) | ||||||
|     children = list(common.P_albums(child_ids, response_type='json')) |     children = list(common.P_albums(child_ids, response_type='json')) | ||||||
|     album.remove_children(children, commit=True) |     album.remove_children(children, commit=True) | ||||||
|     response = etiquette.jsonify.album(album) |     response = etiquette.jsonify.album(album) | ||||||
|  | @ -96,7 +98,7 @@ def post_album_add_photo(album_id): | ||||||
|     ''' |     ''' | ||||||
|     album = common.P_album(album_id, response_type='json') |     album = common.P_album(album_id, response_type='json') | ||||||
| 
 | 
 | ||||||
|     photo_ids = etiquette.helpers.comma_space_split(request.form['photo_id']) |     photo_ids = stringtools.comma_space_split(request.form['photo_id']) | ||||||
|     photos = list(common.P_photos(photo_ids, response_type='json')) |     photos = list(common.P_photos(photo_ids, response_type='json')) | ||||||
|     album.add_photos(photos, commit=True) |     album.add_photos(photos, commit=True) | ||||||
|     response = etiquette.jsonify.album(album) |     response = etiquette.jsonify.album(album) | ||||||
|  | @ -110,7 +112,7 @@ def post_album_remove_photo(album_id): | ||||||
|     ''' |     ''' | ||||||
|     album = common.P_album(album_id, response_type='json') |     album = common.P_album(album_id, response_type='json') | ||||||
| 
 | 
 | ||||||
|     photo_ids = etiquette.helpers.comma_space_split(request.form['photo_id']) |     photo_ids = stringtools.comma_space_split(request.form['photo_id']) | ||||||
|     photos = list(common.P_photos(photo_ids, response_type='json')) |     photos = list(common.P_photos(photo_ids, response_type='json')) | ||||||
|     album.remove_photos(photos, commit=True) |     album.remove_photos(photos, commit=True) | ||||||
|     response = etiquette.jsonify.album(album) |     response = etiquette.jsonify.album(album) | ||||||
|  |  | ||||||
|  | @ -3,6 +3,7 @@ import traceback | ||||||
| import urllib.parse | import urllib.parse | ||||||
| 
 | 
 | ||||||
| from voussoirkit import cacheclass | from voussoirkit import cacheclass | ||||||
|  | from voussoirkit import stringtools | ||||||
| 
 | 
 | ||||||
| import etiquette | import etiquette | ||||||
| 
 | 
 | ||||||
|  | @ -80,7 +81,7 @@ def post_photo_delete(photo_id): | ||||||
| 
 | 
 | ||||||
| def post_photo_add_remove_tag_core(photo_ids, tagname, add_or_remove): | def post_photo_add_remove_tag_core(photo_ids, tagname, add_or_remove): | ||||||
|     if isinstance(photo_ids, str): |     if isinstance(photo_ids, str): | ||||||
|         photo_ids = etiquette.helpers.comma_space_split(photo_ids) |         photo_ids = stringtools.comma_space_split(photo_ids) | ||||||
| 
 | 
 | ||||||
|     photos = list(common.P_photos(photo_ids, response_type='json')) |     photos = list(common.P_photos(photo_ids, response_type='json')) | ||||||
|     tag = common.P_tag(tagname, response_type='json') |     tag = common.P_tag(tagname, response_type='json') | ||||||
|  | @ -156,7 +157,7 @@ def post_photo_generate_thumbnail(photo_id): | ||||||
| 
 | 
 | ||||||
| def post_photo_refresh_metadata_core(photo_ids): | def post_photo_refresh_metadata_core(photo_ids): | ||||||
|     if isinstance(photo_ids, str): |     if isinstance(photo_ids, str): | ||||||
|         photo_ids = etiquette.helpers.comma_space_split(photo_ids) |         photo_ids = stringtools.comma_space_split(photo_ids) | ||||||
| 
 | 
 | ||||||
|     photos = list(common.P_photos(photo_ids, response_type='json')) |     photos = list(common.P_photos(photo_ids, response_type='json')) | ||||||
| 
 | 
 | ||||||
|  | @ -199,7 +200,7 @@ def post_photo_unset_searchhidden(photo_id): | ||||||
| 
 | 
 | ||||||
| def post_batch_photos_searchhidden_core(photo_ids, searchhidden): | def post_batch_photos_searchhidden_core(photo_ids, searchhidden): | ||||||
|     if isinstance(photo_ids, str): |     if isinstance(photo_ids, str): | ||||||
|         photo_ids = etiquette.helpers.comma_space_split(photo_ids) |         photo_ids = stringtools.comma_space_split(photo_ids) | ||||||
| 
 | 
 | ||||||
|     photos = list(common.P_photos(photo_ids, response_type='json')) |     photos = list(common.P_photos(photo_ids, response_type='json')) | ||||||
| 
 | 
 | ||||||
|  | @ -235,7 +236,7 @@ def get_clipboard_page(): | ||||||
| def post_batch_photos_photo_cards(): | def post_batch_photos_photo_cards(): | ||||||
|     photo_ids = request.form['photo_ids'] |     photo_ids = request.form['photo_ids'] | ||||||
| 
 | 
 | ||||||
|     photo_ids = etiquette.helpers.comma_space_split(photo_ids) |     photo_ids = stringtools.comma_space_split(photo_ids) | ||||||
|     photos = list(common.P_photos(photo_ids, response_type='json')) |     photos = list(common.P_photos(photo_ids, response_type='json')) | ||||||
| 
 | 
 | ||||||
|     # Photo filenames are prevented from having colons, so using it as a split |     # Photo filenames are prevented from having colons, so using it as a split | ||||||
|  | @ -294,7 +295,7 @@ def post_batch_photos_download_zip(): | ||||||
|     that they want, and then they can retrieve the zip itself via GET. |     that they want, and then they can retrieve the zip itself via GET. | ||||||
|     ''' |     ''' | ||||||
|     photo_ids = request.form['photo_ids'] |     photo_ids = request.form['photo_ids'] | ||||||
|     photo_ids = etiquette.helpers.comma_space_split(photo_ids) |     photo_ids = stringtools.comma_space_split(photo_ids) | ||||||
| 
 | 
 | ||||||
|     photos = list(common.P_photos(photo_ids, response_type='json')) |     photos = list(common.P_photos(photo_ids, response_type='json')) | ||||||
|     if not photos: |     if not photos: | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue