Exemple #1
0
    def load(self, id: str):

        # Validate the package id.
        PackageId(id)

        path = self.package_path(id)
        if not os.path.exists(path):
            raise PackageNotFound(id)

        filename = os.path.join(path, "pkginfo.json")
        try:
            pkginfo = load_json(filename)
        except OSError as ex:
            raise PackageError("No / unreadable pkginfo.json in {0}: {1}".format(id, ex.strerror)) from ex

        if not isinstance(pkginfo, dict):
            raise PackageError("Usage should be a dictionary, not a {0}".format(type(pkginfo).__name__))

        return Package(path, id, pkginfo)
Exemple #2
0
 def remove(self, id):
     path = self.package_path(id)
     if not os.path.exists(path):
         raise PackageNotFound(id)
     remove_directory(path)
Exemple #3
0
 def remove(self, id):
     path = self.package_path(id)
     if not os.path.exists(path):
         raise PackageNotFound(id)
     shutil.rmtree(path)