def init(self, password=None):
        global rar_executable_version
        self.password = password
        
        
        stdoutdata, stderrdata = self.call('v', []).communicate()
        
        for line in stderrdata.splitlines():
            if line.strip().startswith("Cannot open"):
                raise FileOpenError
            if line.find("CRC failed")>=0:
                raise IncorrectRARPassword   
        accum = []
        source = iter(stdoutdata.splitlines())
        line = ''
        while not (line.startswith('UNRAR')):
            line = source.next()
        signature = line
        # The code below is mighty flaky
        # and will probably crash on localized versions of RAR
        # but I see no safe way to rewrite it using a CLI tool
        if signature.startswith("UNRAR 4"):
            rar_executable_version = 4
            while not (line.startswith('Comment:') or line.startswith('Pathname/Comment')):
                if line.strip().endswith('is not RAR archive'):
                    raise InvalidRARArchive
                line = source.next()
            while not line.startswith('Pathname/Comment'):
                accum.append(line.rstrip('\n'))
                line = source.next()
            if len(accum):
                accum[0] = accum[0][9:] # strip out "Comment:" part
                self.comment = '\n'.join(accum[:-1])
            else:
                self.comment = None
        elif signature.startswith("UNRAR 5"):
            rar_executable_version = 5
            line = source.next()
            while not line.startswith('Archive:'):
                if line.strip().endswith('is not RAR archive'):
                    raise InvalidRARArchive
                accum.append(line.rstrip('\n'))
                line = source.next()
            if len(accum):
                self.comment = '\n'.join(accum[:-1]).strip()
            else:
                self.comment = None
        else:
            raise UnpackerNotInstalled("Unsupported RAR version, expected 4.x or 5.x, found: " 
                    + signature.split(" ")[1])
dataset/ETHPy150Open beville/ComicStreamer/libs/comictaggerlib/UnRAR2/unix.py/RarFileImplementation.init/original