]> git.decadent.org.uk Git - dak.git/blobdiff - daklib/dbconn.py
Merge remote branch 'ftpmaster/master' into psimport
[dak.git] / daklib / dbconn.py
index 6782c081145944e57c22a1bf718872e00c7106c9..4d30e663b994fee443f87aa120dbca0fb9bc1a03 100755 (executable)
@@ -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')