Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def unlink(self, pkg, delete=False):
pkg = self.parse_pkg_src(pkg)
pkg_dir = self.get_package_directory(pkg.to_fname())
unlink_dir = self.get_unlink_directory(pkg.to_fname())
self.log("Unlink:", pkg_dir)
if os.path.exists(pkg_dir):
if util.USE_SYMLINKS:
util.rm_symlink_from(os.path.join(pkg_dir, 'install'), self.prefix)
else:
util.rm_dup_dir(os.path.join(pkg_dir, 'install'), self.prefix, remove_both=False)
util.rm_empty_dirs(self.prefix)
if delete: shutil.rmtree(pkg_dir)
else:
util.mkdir(self.get_unlink_directory())
os.rename(pkg_dir, unlink_dir)
def clean(self):
if util.USE_SYMLINKS:
util.delete_dir(self.get_private_path())
util.rm_symlink_dir(self.prefix)
util.rm_empty_dirs(self.prefix)
else:
for p in self.list():
self.remove(p)
util.delete_dir(self.get_private_path())