Move truthystring to stringtools.
This commit is contained in:
		
							parent
							
								
									54082e82aa
								
							
						
					
					
						commit
						0418cae57a
					
				
					 2 changed files with 3 additions and 11 deletions
				
			
		|  | @ -3,6 +3,7 @@ import itertools | ||||||
| 
 | 
 | ||||||
| from voussoirkit import flasktools | from voussoirkit import flasktools | ||||||
| from voussoirkit import pathclass | from voussoirkit import pathclass | ||||||
|  | from voussoirkit import stringtools | ||||||
| 
 | 
 | ||||||
| import ycdl | import ycdl | ||||||
| 
 | 
 | ||||||
|  | @ -130,7 +131,7 @@ def post_delete_channel(channel_id): | ||||||
| @site.route('/channel/<channel_id>/refresh', methods=['POST']) | @site.route('/channel/<channel_id>/refresh', methods=['POST']) | ||||||
| def post_refresh_channel(channel_id): | def post_refresh_channel(channel_id): | ||||||
|     force = request.form.get('force', False) |     force = request.form.get('force', False) | ||||||
|     force = ycdl.helpers.truthystring(force) |     force = stringtools.truthystring(force, False) | ||||||
|     try: |     try: | ||||||
|         channel = common.ycdldb.get_channel(channel_id) |         channel = common.ycdldb.get_channel(channel_id) | ||||||
|     except ycdl.exceptions.NoSuchChannel as exc: |     except ycdl.exceptions.NoSuchChannel as exc: | ||||||
|  | @ -142,7 +143,7 @@ def post_refresh_channel(channel_id): | ||||||
| @site.route('/refresh_all_channels', methods=['POST']) | @site.route('/refresh_all_channels', methods=['POST']) | ||||||
| def post_refresh_all_channels(): | def post_refresh_all_channels(): | ||||||
|     force = request.form.get('force', False) |     force = request.form.get('force', False) | ||||||
|     force = ycdl.helpers.truthystring(force) |     force = stringtools.truthystring(force, False) | ||||||
|     common.ycdldb.refresh_all_channels(force=force, skip_failures=True) |     common.ycdldb.refresh_all_channels(force=force, skip_failures=True) | ||||||
|     return flasktools.make_json_response({}) |     return flasktools.make_json_response({}) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,9 +0,0 @@ | ||||||
| def truthystring(s): |  | ||||||
|     if isinstance(s, (bool, int)) or s is None: |  | ||||||
|         return s |  | ||||||
|     s = s.lower() |  | ||||||
|     if s in {'1', 'true', 't', 'yes', 'y', 'on'}: |  | ||||||
|         return True |  | ||||||
|     if s in {'null', 'none'}: |  | ||||||
|         return None |  | ||||||
|     return False |  | ||||||
		Loading…
	
		Reference in a new issue