I don\'t want to use OS commands as that makes it is OS dependent.
This is available in tarfile, tarfile.is_tarfile(filename), to check if
tarfile
tarfile.is_tarfile(filename)
Try something like this:
def is_empty(gzfile): size = gzfile.read(). if len(size) > 0: gzfile.rewind() return False else: return True