]> code.delx.au - monosys/commitdiff
pacorphan: tidying
authorJames Bunton <jamesbunton@delx.net.au>
Sat, 19 Apr 2014 01:26:36 +0000 (11:26 +1000)
committerJames Bunton <jamesbunton@delx.net.au>
Sat, 19 Apr 2014 01:26:36 +0000 (11:26 +1000)
bin/pacorphan

index e5ad759aa1db2f78d622ba9a1d25f23853300641..eb793cdaa5f6b053f71dd8763c03e91ed7796fdd 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 import codecs
 import subprocess
@@ -7,12 +7,8 @@ import sys
 
 PACORPHAN_PATH = os.path.expanduser("~/.pacorphan")
 
-keep_pkg_list = []
-mark_explicit_list = []
-need_install_list = []
-unneeded_pkg_list = []
-installed_pkg_list = []
-explicit_pkg_list = []
+def run(cmd):
+    return subprocess.check_output(cmd).decode("utf-8").split("\n")
 
 def strip_comment(line):
     pos = line.find("#")
@@ -20,6 +16,14 @@ def strip_comment(line):
         line = line[:pos]
     return line.strip()
 
+
+keep_pkg_list = []
+mark_explicit_list = []
+need_install_list = []
+unneeded_pkg_list = []
+installed_pkg_list = []
+explicit_pkg_list = []
+
 for filename in os.listdir(PACORPHAN_PATH):
     if filename.startswith("."):
         continue
@@ -31,13 +35,13 @@ for filename in os.listdir(PACORPHAN_PATH):
         if pkg:
             keep_pkg_list.append(pkg.strip())
 
-for pkg in subprocess.check_output(["pacman", "-Qq"]).decode("utf-8").split():
+for pkg in run(["pacman", "-Qq"]):
     installed_pkg_list.append(pkg.strip())
 
-for pkg in subprocess.check_output(["pacman", "-Qtq"]).decode("utf-8").split():
+for pkg in run(["pacman", "-Qtq"]):
     unneeded_pkg_list.append(pkg.strip())
 
-for pkg in subprocess.check_output(["pacman", "-Qeq"]).decode("utf-8").split():
+for pkg in run(["pacman", "-Qeq"]):
     explicit_pkg_list.append(pkg.strip())