def generate_to(self, worksheet, row):
        '''Generate row report.

        Generates a row report of the item represented by this instance and
        inserts it into a given worksheet at a specified row number.

        :param worksheet: Reference to a worksheet in which to insert row
        report.

        :param row: Row number.
        '''
        super(ItemImage, self).generate_to(worksheet, row)

        embedded = False
        fmt = self.generator.formats
        worksheet.write(row, 3, "image", fmt['type_image'])
        worksheet.write_url(row, 5, self.data[0], fmt['link'])

        try:
            if self.data:
                image = self.resize_image(StringIO(self.data[1]))
                worksheet.insert_image(row, 4, 'image',
                                       {'image_data': image})
                embedded = True
        except:
            # We probably wrongly ignoring the exception.  Should really at
            # least log it somewhere.
            pass

        # Attempt to retrieve image data from the image URL if image data not
        # present already above or something failed whilst recreating image
        # from base64 encoding.
        if not embedded:
            url = self.data[0]
            if url:
                image = self.resize_image(BytesIO(urlopen(url).read()))
                worksheet.insert_image(row, 4, url, {'image_data': image})
                embedded = True
            else:
                worksheet.write(row, 4, '<unavailable>')

        if embedded:
            worksheet.set_row(row, 40)
def generate_to ( self , worksheet , row ) : super ( ItemImage , self ) . generate_to ( worksheet , row ) embedded = False fmt = self . generator . formats worksheet . write ( row , 3 , "image" , fmt [ 'type_image' ] ) worksheet . write_url ( row , 5 , self . data [ 0 ] , fmt [ 'link' ] ) try : if self . data : image = self . resize_image ( StringIO ( self . data [ 1 ] ) ) worksheet . insert_image ( row , 4 , 'image' , { 'image_data' : image } ) embedded = True except : pass if not embedded : url = self . data [ 0 ] if url : image = self . resize_image ( BytesIO ( urlopen ( url ) . read ( ) ) ) worksheet . insert_image ( row , 4 , url , { 'image_data' : image } ) embedded = True else : worksheet . write ( row , 4 , '<unavailable>' ) if embedded : worksheet . set_row ( row , 40 )
Generate row report.

        Generates a row report of the item represented by this instance and
        inserts it into a given worksheet at a specified row number.

        :param worksheet: Reference to a worksheet in which to insert row
        report.

        :param row: Row number.