Explorar o código

dpkg_which: fail if cmd not installed via dpkg

Fabian Peter Hammerle %!s(int64=5) %!d(string=hai) anos
pai
achega
010ff548d6
Modificáronse 1 ficheiros con 3 adicións e 2 borrados
  1. 3 2
      rc.xsh

+ 3 - 2
rc.xsh

@@ -56,8 +56,9 @@ def dpkg_which(cmd):
     cmd_path = shutil.which(cmd)
     assert cmd_path, 'cmd {!r} not found'.format(cmd)
     matches = dpkg_search(cmd_path)
-    assert len(matches) in [0, 1]
-    return matches[0] if len(matches) == 1 else None
+    assert len(matches) != 0, '{!r} not installed via dpkg'.format(cmd_path)
+    assert len(matches) == 1
+    return matches[0]
 
 def locate(*patterns, match_all=True, ignore_case=True):
     params = []