[diffoscope] 06/07: Use try-except idiom instead of ``if`` in RequiredToolNotFound.get_package

Chris Lamb chris at chris-lamb.co.uk
Mon Aug 15 21:55:54 CEST 2016


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository diffoscope.

commit 73f0a367394dbca3dfc95a03a6eb229fbe9c21a4
Author: Chris Lamb <lamby at debian.org>
Date:   Mon Aug 15 20:52:03 2016 +0100

    Use try-except idiom instead of ``if`` in RequiredToolNotFound.get_package
---
 diffoscope/exc.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/diffoscope/exc.py b/diffoscope/exc.py
index 1d5a433..5f56fe4 100644
--- a/diffoscope/exc.py
+++ b/diffoscope/exc.py
@@ -185,7 +185,9 @@ class RequiredToolNotFound(Exception):
     def get_package(self):
         from . import get_current_os
 
-        providers = RequiredToolNotFound.PROVIDERS.get(self.command, None)
-        if not providers:
+        try:
+            providers = RequiredToolNotFound.PROVIDERS[self.command]
+        except KeyError:
             return None
+
         return providers.get(get_current_os(), None)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list