Python shutil._UNPACK_FORMATS Examples

The following are 11 code examples of shutil._UNPACK_FORMATS(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module shutil , or try the search function .
Example #1
Source Project: jawfish   Author: war-and-code   File: regrtest.py    License: MIT License 5 votes vote down vote up
def get_shutil_unpack_formats(self):
        return shutil._UNPACK_FORMATS, shutil._UNPACK_FORMATS.copy() 
Example #2
Source Project: jawfish   Author: war-and-code   File: regrtest.py    License: MIT License 5 votes vote down vote up
def restore_shutil_unpack_formats(self, saved):
        shutil._UNPACK_FORMATS = saved[0]
        shutil._UNPACK_FORMATS.clear()
        shutil._UNPACK_FORMATS.update(saved[1]) 
Example #3
Source Project: dephell   Author: dephell   File: vendor_download.py    License: MIT License 5 votes vote down vote up
def _extract_modules(self, dep, archive_path: Path, output_path: Path) -> bool:
        # say to shutils that wheel can be parsed as zip
        if 'wheel' not in shutil._UNPACK_FORMATS:  # type: ignore
            shutil.register_unpack_format(
                name='wheel',
                extensions=['.whl'],
                function=shutil._unpack_zipfile,  # type: ignore
            )

        with TemporaryDirectory(suffix=dep.name) as package_path:  # type: Path # type: ignore
            package_path = Path(package_path)
            shutil.unpack_archive(str(archive_path), str(package_path))
            if len(list(package_path.iterdir())) == 1:
                package_path = next(package_path.iterdir())

            # find modules
            root = PackageRoot(name=dep.name, path=package_path)
            if not root.packages:
                self.logger.error('cannot find modules', extra=dict(
                    dependency=dep.name,
                    version=dep.group.best_release.version,
                ))
                return False

            # copy modules
            module_path = root.packages[0].path
            module_name = root.packages[0].module
            self.logger.info('copying module...', extra=dict(
                path=str(module_path.relative_to(package_path)),
                dependency=dep.name,
            ))
            shutil.copytree(
                src=str(module_path),
                dst=str(output_path.joinpath(*module_name.split('.'))),
            )
            return True 
Example #4
Source Project: Fluid-Designer   Author: Microvellum   File: regrtest.py    License: GNU General Public License v3.0 5 votes vote down vote up
def get_shutil_unpack_formats(self):
        return shutil._UNPACK_FORMATS, shutil._UNPACK_FORMATS.copy() 
Example #5
Source Project: Fluid-Designer   Author: Microvellum   File: regrtest.py    License: GNU General Public License v3.0 5 votes vote down vote up
def restore_shutil_unpack_formats(self, saved):
        shutil._UNPACK_FORMATS = saved[0]
        shutil._UNPACK_FORMATS.clear()
        shutil._UNPACK_FORMATS.update(saved[1]) 
Example #6
Source Project: ironpython3   Author: IronLanguages   File: regrtest.py    License: Apache License 2.0 5 votes vote down vote up
def get_shutil_unpack_formats(self):
        return shutil._UNPACK_FORMATS, shutil._UNPACK_FORMATS.copy() 
Example #7
Source Project: ironpython3   Author: IronLanguages   File: regrtest.py    License: Apache License 2.0 5 votes vote down vote up
def restore_shutil_unpack_formats(self, saved):
        shutil._UNPACK_FORMATS = saved[0]
        shutil._UNPACK_FORMATS.clear()
        shutil._UNPACK_FORMATS.update(saved[1]) 
Example #8
Source Project: Project-New-Reign---Nemesis-Main   Author: ShikyoKira   File: regrtest.py    License: GNU General Public License v3.0 5 votes vote down vote up
def get_shutil_unpack_formats(self):
        return shutil._UNPACK_FORMATS, shutil._UNPACK_FORMATS.copy() 
Example #9
Source Project: Project-New-Reign---Nemesis-Main   Author: ShikyoKira   File: regrtest.py    License: GNU General Public License v3.0 5 votes vote down vote up
def restore_shutil_unpack_formats(self, saved):
        shutil._UNPACK_FORMATS = saved[0]
        shutil._UNPACK_FORMATS.clear()
        shutil._UNPACK_FORMATS.update(saved[1]) 
Example #10
Source Project: android_universal   Author: bkerler   File: save_env.py    License: MIT License 5 votes vote down vote up
def get_shutil_unpack_formats(self):
        return shutil._UNPACK_FORMATS, shutil._UNPACK_FORMATS.copy() 
Example #11
Source Project: android_universal   Author: bkerler   File: save_env.py    License: MIT License 5 votes vote down vote up
def restore_shutil_unpack_formats(self, saved):
        shutil._UNPACK_FORMATS = saved[0]
        shutil._UNPACK_FORMATS.clear()
        shutil._UNPACK_FORMATS.update(saved[1])