From d55cc5c58a2f3a062a524978a8a7adff4bf5fcee Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Fri, 1 Jan 2021 13:39:22 -0800 Subject: [PATCH] Use a dict instead of if/elif. --- etiquette/searchhelpers.py | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/etiquette/searchhelpers.py b/etiquette/searchhelpers.py index b482329..d798638 100644 --- a/etiquette/searchhelpers.py +++ b/etiquette/searchhelpers.py @@ -348,22 +348,13 @@ def normalize_orderby(orderby, warning_bag=None): raise exc column_friendly = column - column_expanded = column - - if column_expanded == 'random': - column_expanded = 'RANDOM()' - - elif column_expanded == 'area': - column_expanded = '(width * height)' - - 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)' + column_expanded = { + 'random': 'RANDOM()', + 'area': '(width * height)', + 'basename': 'COALESCE(override_filename, basename)', + 'bitrate': '((bytes / 128) / duration)', + 'ratio': '(width / height)', + }.get(column, column) final_orderby.append( (column_friendly, column_expanded, direction) )