Created
April 20, 2010 16:35
-
-
Save jsoffer/372718 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess as sp | |
def instalados(): | |
proceso = sp.Popen('pkg_info', stdout=sp.PIPE) | |
lineas = proceso.communicate()[0].splitlines() | |
return map (lambda k: k.split()[0], lineas) # solo la primera palabra | |
def filtra(xs): | |
return filter(lambda k: len(k) > 0 and k.find('Required') != 0 and k.find('Information') != 0 and k[0] != '\n', xs) | |
def dependencias(xs): | |
ret = [] | |
for x in xs: | |
proceso = sp.Popen(["pkg_info", "-R", x], stdout=sp.PIPE) | |
lineas = proceso.communicate()[0].splitlines() | |
ret.append(lineas) | |
return map(filtra, ret) | |
# i = instalados() | |
# pares = zip(i, dependencias(i)) | |
# for (x,depx) in pares: | |
# for y in depx: | |
# print y + " -> " + x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment