How to use the py7zr.is_7zfile function in py7zr

To help you get started, we’ve selected a few py7zr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github miurahr / aqtinstall / aqt / installer.py View on Github external
if r.status_code == 302:
                newurl = altlink(r.url)
                # newurl = r.headers['Location']
                self.logger.info('Redirected to new URL: {}'.format(newurl))
                r = requests.get(newurl, stream=True)
        except requests.exceptions.ConnectionError as e:
            self.logger.warning("Caught download error: %s" % e.args)
            return False
        else:
            with open(archive, 'wb') as fd:
                for chunk in r.iter_content(chunk_size=8196):
                    fd.write(chunk)
            self.logger.info("-Extracting {}...".format(archive))

            if sys.version_info > (3, 5):
                if not py7zr.is_7zfile(archive):
                    raise BadPackageFile
            if command is None:
                py7zr.SevenZipFile(archive).extractall(path=path)
            else:
                if path is not None:
                    run([command, 'x', '-aoa', '-bd', '-y', '-o{}'.format(path), archive])
                else:
                    run([command, 'x', '-aoa', '-bd', '-y', archive])
            os.unlink(archive)
        return True

py7zr

Pure python 7-zip library

LGPL-2.1
Latest version published 5 months ago

Package Health Score

82 / 100
Full package analysis

Similar packages