Пример #1
0
 def save(self, save_context, picture=None, return_before_saving=False):
     photo = self.photo
     if picture is None:
         picture = Picture()
     img_url = photo.original_url or photo.large_url or photo.medium_url
     picture.blob.store(iterate_file_object(urlopen(img_url)))
     picture.blob.mime_type = 'image/jpeg'
     license_elt = picture.common.licenses.new_item()
     license_elt.href = photo['license']
     picture.common.licenses.array = [license_elt]
     picture.common.patch_from_blueprint(None, save_context)
     picture.credit.title.text = photo['title']['_content']
     picture.credit.original_url.href = photo.page_url
     picture.credit.author.text = "%(realname)s (%(username)s)" % photo['owner']
     picture.credit.author_url.href = photo.userpage_url
     if photo['rotation'] and photo.original_url:
         picture.rotation = unicode(360 - int(photo['rotation']))
     if return_before_saving:
         return
     return picture.save()
Пример #2
0
 def __getitem__(self, key):
     return iterate_file_object(self.__get_file_object(key))
Пример #3
0
 def __getitem__(self, key):
     try:
         return iterate_file_object(urlopen(self.__remote_url(key)))
     except HTTPError:
         raise KeyError(key)