Howto parse a debian changes file in python

Firts post in English (just a test :). If yo want to parse a debian package changes file in python is so easy as:

import os
import GnuPGInterface
import syck

changes_file = '/tmp/factoriapegaso-panel_0.2.6-4_amd64.changes'

gnupg = GnuPGInterface.GnuPG()
ciphertext = open(changes_file).read()
p2 = gnupg.run(['--decrypt'], create_fhs=['stdin', 'stdout'])
p2.handles['stdin'].write(ciphertext)
p2.handles['stdin'].close()
decrypted_plaintext = p2.handles['stdout'].read()
p2.handles['stdout'].close()
#Puede fallar por no tener la llave GPG
try:
        p2.wait()
except:
        pass

changes_info = syck.load(decrypted_plaintext)


print "tenemos:"
print changes_info
Marcar como favorito enlace permanente.

Deja una respuesta