def __init__(self, file_, storage=None): if not file_: raise ThumbnailError('File is empty.') # figure out name if hasattr(file_, 'name'): self.name = file_.name else: self.name = force_unicode(file_) # figure out storage if storage is not None: self.storage = storage elif hasattr(file_, 'storage'): self.storage = file_.storage elif url_pat.match(self.name): self.storage = UrlStorage() else: self.storage = default_storage if hasattr(self.storage, 'location'): location = self.storage.location if not self.storage.location.endswith("/"): location += "/" if self.name.startswith(location): self.name = self.name[len(location):]
def __init__(self, file_, storage=None): if not file_: raise ThumbnailError('File is empty.') # figure out name if hasattr(file_, 'name'): self.name = file_.name else: self.name = force_unicode(file_) # figure out storage if storage is not None: self.storage = storage elif hasattr(file_, 'storage'): self.storage = file_.storage elif url_pat.match(self.name): self.storage = UrlStorage() else: self.storage = default_storage