X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fdbconn.py;h=4d30e663b994fee443f87aa120dbca0fb9bc1a03;hb=b8690d6b1256a4a95198b874d9eb1aab62a825fb;hp=25fd9c6ee578fa215829afea7005e9c78a3b2755;hpb=8e32a7b21801472eb15b034e407ea04de053feb9;p=dak.git diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 25fd9c6e..4d30e663 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -529,6 +529,25 @@ class DBBinary(ORMObject): dpkg.stdout.close() dpkg.wait() + def read_control(self): + ''' + Reads the control information from a binary. + + @rtype: tuple + @return: (stanza, controldict) stanza is the text of the control + section. controldict is the information in a dictionary + form + ''' + import apt_inst, apt_pk + fullpath = self.poolfile.fullpath + deb_file = open(fullpath, 'r') + stanza = apt_inst.debExtractControl(deb_file).rstrip() + control = dict(apt_pkg.TagSection(stanza)) + deb_file.close() + + return stanza, control + + __all__.append('DBBinary') @session_wrapper @@ -2176,6 +2195,20 @@ class DBSource(ORMObject): return ['source', 'version', 'install_date', 'maintainer', \ 'changedby', 'poolfile', 'install_date'] + def read_control(self): + ''' + Reads the control information from a dsc + + @rtype: tuple + @return: (stanza, controldict) stanza is the text of the control + section. controldict is the information in a dictionary + form + ''' + from debian.debfile import Deb822 + fullpath = self.poolfile.fullpath + fields = Deb822(open(self.poolfile.fullpath, 'r')) + return fields + metadata = association_proxy('key', 'value') __all__.append('DBSource') @@ -2992,7 +3025,7 @@ class DBConn(object): backref=backref('binaries', lazy='dynamic')), extra_sources = relation(DBSource, secondary=self.tbl_extra_src_references, backref=backref('extra_binary_references', lazy='dynamic')), - key = relation(BinaryMetadata, + key = relation(BinaryMetadata, cascade='all', collection_class=attribute_mapped_collection('key'))), extension = validator) @@ -3164,7 +3197,7 @@ class DBConn(object): suites = relation(Suite, secondary=self.tbl_src_associations, backref=backref('sources', lazy='dynamic')), srcuploaders = relation(SrcUploader), - key = relation(SourceMetadata, + key = relation(SourceMetadata, cascade='all', collection_class=attribute_mapped_collection('key'))), extension = validator)