diff options
author | Joseph Rice <mrwildrice@gmail.com> | 2019-10-09 22:09:23 -0400 |
---|---|---|
committer | Joseph Rice <mrwildrice@gmail.com> | 2019-10-11 03:13:10 -0400 |
commit | dafcebf172d761e813308f72bee0f502550b130f (patch) | |
tree | 56a93235f1a2eae3c1e73645b6a7304a39e02568 /ranger | |
parent | fc703385d542340311e62608f9d63d35b4c865c5 (diff) | |
download | ranger-dafcebf172d761e813308f72bee0f502550b130f.tar.gz |
made variables in image displayer registry accessors less generic
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/ext/img_display.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index 939eacb5..7e911848 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -85,15 +85,19 @@ IMAGE_DISPLAYER_REGISTRY = defaultdict(fallback_image_displayer) def register_image_displayer(nickname=None): """Register an ImageDisplayer by nickname if available.""" - def decorator(cls): - IMAGE_DISPLAYER_REGISTRY[nickname or cls.__name__] = cls - return cls + def decorator(image_displayer_class): + if nickname: + registry_key = nickname + else: + registry_key = image_displayer_class.__name__ + IMAGE_DISPLAYER_REGISTRY[registry_key] = image_displayer_class + return image_displayer_class return decorator -def get_image_displayer(key): - cls = IMAGE_DISPLAYER_REGISTRY[key] - return cls() +def get_image_displayer(registry_key): + image_displayer_class = IMAGE_DISPLAYER_REGISTRY[registry_key] + return image_displayer_class() class ImageDisplayer(object): |