Exemplo n.º 1
0
    def testGNUArchiveLongNames(self):
        a = ar.Archive(self.getArchiveFile('sortedlen.a'))
        b = [x.name for x in a]
        self.assertEquals(b, [
            'short', 'notlong', 'thisisareallylongfilename',
            'ANOTHERREALLYLONGFILENAME'
        ])

        a = ar.Archive(self.getArchiveFile('mixedlen.a'))
        b = [x.name for x in a]
        self.assertEquals(b, [
            'short', 'thisisareallylongfilename', 'notlong',
            'ANOTHERREALLYLONGFILENAME'
        ])
Exemplo n.º 2
0
    def testTruncatedArchive(self):
        a = ar.Archive(self.getArchiveFile('testshortheader.a'))

        def parseArchive():
            b = [x.name for x in a]

        self.assertRaises(ar.ArchiveError, parseArchive)
Exemplo n.º 3
0
    def testNotAnArArchive(self):
        a = ar.Archive(self.getArchiveFile('unstripped_archive.o'))

        def parseArchive():
            b = [x.name for x in a]

        self.assertRaises(ar.ArchiveError, parseArchive)
Exemplo n.º 4
0
    def testDeb(self):
        a = ar.Archive(self.getArchiveFile('testempty.deb'))
        b = [x.name for x in a]
        self.assertEquals(
            b, ['debian-binary', 'ignore1', 'control.tar.gz', 'ignore2'])

        a = ar.Archive(self.getArchiveFile('test.deb'))
        b = [x.name for x in a]
        self.assertEquals(
            b, ['debian-binary', 'control.tar.bz2', 'data.tar.bz2', 'ignore1'])

        a = ar.Archive(self.getArchiveFile('bash.deb'))
        c = [x for x in a]
        b = [x.name for x in c]
        self.assertEquals(b,
                          ['debian-binary', 'control.tar.gz', 'data.tar.gz'])
        magic = [x.data.read() for x in c if x.name == 'debian-binary'][0]
        self.assertEquals(magic, '2.0\n')
Exemplo n.º 5
0
 def testArchiveRepr(self):
     timestamp = 1145659903
     import time
     timestr = time.ctime(timestamp)
     a = ar.Archive(self.getArchiveFile('bash.deb'))
     b = [repr(x) for x in a]
     self.assertEquals(b, [
         '<ArFile 0744 0:0          4 %s debian-binary>' % timestr,
         '<ArFile 0744 0:0       5555 %s control.tar.gz>' % timestr,
         '<ArFile 0744 0:0     757749 %s data.tar.gz>' % timestr
     ])
Exemplo n.º 6
0
    def _getControlFileStream(self):
        self._fileObj.seek(0)
        arch = ar.Archive(self._fileObj)
        arr = [x for x in arch if x.name == 'control.tar.gz']
        if not arr:
            raise Error("Unable to find control archive")
        arFile = arr[0]

        try:
            gf = gzip.GzipFile(fileobj=arFile.data)
            tf = tarfile.TarFile(fileobj=gf)
        except IOError, e:
            raise Error("control.tar.gz is not readable: %s" % str(e))
Exemplo n.º 7
0
 def testGNUArchiveSymbolTable(self):
     a = ar.Archive(self.getArchiveFile('unstripped_archive.a'))
     b = [x.name for x in a]
     self.assertEquals(b, ['/', 'unstripped_archive.o'])