Skip to content

Instantly share code, notes, and snippets.

@jsoffer
Created April 20, 2010 16:35
Show Gist options
  • Save jsoffer/372718 to your computer and use it in GitHub Desktop.
Save jsoffer/372718 to your computer and use it in GitHub Desktop.
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