Browse Source

remove func dpkg_search()

Fabian Peter Hammerle 5 years ago
parent
commit
98b7608219
1 changed files with 3 additions and 12 deletions
  1. 3 12
      rc.xsh

+ 3 - 12
rc.xsh

@@ -103,14 +103,6 @@ def chdir(path):
         os.chdir(previous)
         sys.stderr.write('cd {}\n'.format(shlex.quote(previous)))
 
-def dpkg_search(path_search_pattern):
-    assert isinstance(path_search_pattern, str)
-    return re.findall(
-        '^(\S+): (.*)$\n',
-        $(dpkg --search @(path_search_pattern)),
-        flags=re.MULTILINE,
-    )
-
 def dpkg_welse(cmd):
     pkg_name, _ = dpkg_which(cmd)
     return $(dpkg --listfiles @(pkg_name)).split('\n')[:-1]
@@ -118,10 +110,9 @@ def dpkg_welse(cmd):
 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) != 0, '{!r} not installed via dpkg'.format(cmd_path)
-    assert len(matches) == 1
-    return matches[0]
+    search_match = re.search('^(\S+): ', $(dpkg --search @(cmd_path)))
+    assert search_match, f'{cmd_path!r} not installed via dpkg'
+    return search_match.group(1), cmd_path
 
 @contextlib.contextmanager
 def encfs_mount(root_dir_path, mount_point_path, extpass=None):