def lookup_package_bundle(self, name): """Look up a package bundle by name. Args: name (unicode): The name of the package bundle. Returns: PackageBundle: The package bundle, if found, or ``None`` if a bundle with that name doesn't exist. """ package_bundle = self._package_bundle_cache.get(name) if package_bundle is None: path = self._build_package_bundle_path(name) try: package_bundle_data = get_data_loader().load_by_path(path) except LoadDataError as e: raise PackageLookupError(six.text_type(e)) package_bundle = PackageBundle.deserialize( base_url=self.BASE_PATH, manifest_url=path, data=package_bundle_data ) self._package_bundle_cache[name] = package_bundle return package_bundle
def load(self): """Load data from the manifest file. The data from the manifest will be loaded and stored in this instance, allowing the caller to access it. """ # Let the exceptions bubble up. data = get_data_loader().load_by_path(self.absolute_manifest_url) self._releases = [] self._package_rules = [] self.created_timestamp = \ dateutil.parser.parse(data['created_timestamp']) self.last_updated_timestamp = \ dateutil.parser.parse(data['last_updated_timestamp']) self._releases = [ PackageRelease.deserialize(self, releases_data) for releases_data in data['releases'] ] self._package_rules = [ PackageRules.deserialize(self, rules_data) for rules_data in data['package_rules'] ] self._loaded = True
def get_index(self): """Return the root package index from the repository. Returns: rbpkg.repository.package_index.PackageIndex: The root package index. """ if not self._index: manifest_url = self._build_package_index_path() index_data = get_data_loader().load_by_path(manifest_url) self._index = PackageIndex.deserialize(manifest_url, index_data) return self._index