def get_getter(self): """Returns an instance of proper PackageGetter subclass. Always returns the same instance. Returns: Instance of the proper PackageGetter subclass according to self.source_from. Raises: NoSuchSourceException if source to get the package from is unknown NoSuchPackageException if the package is unknown on PyPI """ if not hasattr(self, '_getter'): if self.source_from == 'pypi': if self.name == None: raise exceptions.NameNotSpecifiedException( 'Must specify package when getting from PyPI.') self._getter = package_getters.PypiDownloader( self.get_client(), self.name, self.version, self.save_dir) elif os.path.exists(self.source_from): self._getter = package_getters.LocalFileGetter( self.source_from, self.save_dir) else: raise exceptions.NoSuchSourceException( '"{0}" is neither one of preset sources nor a file.'. format(self.source_from)) return self._getter
def getter(self): """Returns an instance of proper PackageGetter subclass. Always returns the same instance. Returns: Instance of the proper PackageGetter subclass according to provided argument. Raises: NoSuchSourceException if source to get the package from is unknown NoSuchPackageException if the package is unknown on PyPI """ if not hasattr(self, '_getter'): if not self.pypi: self._getter = package_getters.LocalFileGetter( self.package, self.save_dir) else: logger.debug( '{0} does not exist as local file trying PyPI.'.format( self.package)) self._getter = package_getters.PypiDownloader( self.client, self.package, self.version, self.prerelease, self.save_dir) return self._getter