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

detiste-guest pushed a commit to branch master
in repository game-data-packager.

commit ac7af4dc4ad8d34130d1731a46afc4345b618c9f
Author: Alexandre Detiste <alexandre.deti...@gmail.com>
Date:   Wed Apr 29 10:35:45 2015 +0200

    util: add fast is_avaible(package)
    
    based on apt-cache bash completion
---
 game_data_packager/util.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/game_data_packager/util.py b/game_data_packager/util.py
index 2453eec..dda3976 100644
--- a/game_data_packager/util.py
+++ b/game_data_packager/util.py
@@ -19,6 +19,7 @@
 import os
 import shutil
 import stat
+import subprocess
 
 KIBIBYTE = 1024
 MEBIBYTE = KIBIBYTE * KIBIBYTE
@@ -92,6 +93,15 @@ def is_installed(package):
 
     return os.path.isdir(os.path.join('/usr/share/doc', package))
 
+def is_avaible(package):
+    proc = subprocess.Popen(['apt-cache', 'pkgnames', package],
+                            universal_newlines=True,
+                            stdout=subprocess.PIPE)
+    for line in proc.stdout:
+        if line.rstrip() == package:
+            return True
+    return False
+
 def prefered_lang():
     lang_raw = []
     if 'LANGUAGE' in os.environ:

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-games/game-data-packager.git

_______________________________________________
Pkg-games-commits mailing list
Pkg-games-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

Reply via email to