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

Leave a Comment

Tu dirección de correo electrónico no será publicada.

Puedes usar las siguientes etiquetas y atributos HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>