dsoprea / PyEasyArchive

A very intuitive and useful adapter to libarchive for universal archive access.
MIT License
96 stars 33 forks source link

Can't figure out how to handle .gz files with no content list (initrd.gz example) #19

Closed SkyLeach closed 7 years ago

SkyLeach commented 7 years ago

test code:

    FILE="/Users/magregor/src/imgunbundle/test/test_data/isolinux/initrd.gz"
    import sys, os
    import pprint
    import libarchive.public as la
    with open(FILE, 'rb') as fh:
        with la.file_reader(fh.name) as lafh:
            count = 0
            for count,entry in enumerate(lafh):
                print str(entry)
                #print entry.filetype
                pprint.pprint(dir(entry.filetype))
            if not count:
                outfile = os.path.splitext(os.path.basename(FILE))[0]
                for entry in la.file_pour(FILE):
                    print(entry)
                print(outfile)
                raise Exception('No count')

result:

    Traceback (most recent call last):
      File "/Users/magregor/tmp/test_lafh.py", line 18, in <module>
        raise Exception('No count')
    Exception: No count
SkyLeach commented 7 years ago

my bad, there is an entry just no name.