Use a dict instead of if/elif.
This commit is contained in:
		
							parent
							
								
									2c29c196a7
								
							
						
					
					
						commit
						d55cc5c58a
					
				
					 1 changed files with 7 additions and 16 deletions
				
			
		|  | @ -348,22 +348,13 @@ def normalize_orderby(orderby, warning_bag=None): | ||||||
|                 raise exc |                 raise exc | ||||||
| 
 | 
 | ||||||
|         column_friendly = column |         column_friendly = column | ||||||
|         column_expanded = column |         column_expanded = { | ||||||
| 
 |             'random': 'RANDOM()', | ||||||
|         if column_expanded == 'random': |             'area': '(width * height)', | ||||||
|             column_expanded = 'RANDOM()' |             'basename': 'COALESCE(override_filename, basename)', | ||||||
| 
 |             'bitrate': '((bytes / 128) / duration)', | ||||||
|         elif column_expanded == 'area': |             'ratio': '(width / height)', | ||||||
|             column_expanded = '(width * height)' |         }.get(column, column) | ||||||
| 
 |  | ||||||
|         elif column_expanded == 'basename': |  | ||||||
|             column_expanded = 'COALESCE(override_filename, basename)' |  | ||||||
| 
 |  | ||||||
|         elif column_expanded == 'bitrate': |  | ||||||
|             column_expanded = '((bytes / 128) / duration)' |  | ||||||
| 
 |  | ||||||
|         elif column_expanded == 'ratio': |  | ||||||
|             column_expanded = '(width / height)' |  | ||||||
| 
 | 
 | ||||||
|         final_orderby.append( (column_friendly, column_expanded, direction) ) |         final_orderby.append( (column_friendly, column_expanded, direction) ) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue