Esempio n. 1
0
 def _get_dimensions(self, size, img=None):
   if size and 'x' in size: # Size can be 'Unknown'.
     w, h = size.split('x')
     if img:
       Util.assert_equals(w, img['width'])
       Util.assert_equals(h, img['height'])
   elif img and img.has_key('width') and img.has_key('height'): # Unlikely
     w = img['width']
     h = img['height']
   else:
     print 'No size info for image: ' + self.page_url
     w = None
     h = None
   return (w, h)
Esempio n. 2
0
  def is_scrape_thumbs_complete(self, thumb):
    info = thumb.get_info()
    try:
      row = self.db.get_row_by_field('album', 'page_url', info['page_url'])
    except Database.DbException:
      return False

    Util.assert_equals(row['parent'], -1)
    for item in ['name', 'date', 'num_items', 'tot_items']:
      Util.assert_equals(str(row[item]), str(info[item]))
    num_albums = self.db.count_rows('album', 'parent > 0')
    num_images = self.db.count_rows('image', 'parent > 0')
    Util.assert_equals(num_albums + num_images, row['tot_items'])
    print ('"%s" has been scraped: %s sub-albums, %s images'
           % (row['name'], num_albums, num_images))
    return True