def set_picture(self, new_file):
        uid = self.target.username
        self.picture.error = None
        error = None

        # No value, exit
        if new_file == '':
            return None

        try:
            validator.validate_file(
                new_file, self.assets_manager.max_size, _(u'File must be less than %d KB'))
        except __HOLE__, e:
            error = e.message
        if imghdr.what(new_file.file) is None:
            error = _(u'Invalid image file')

        if error:
            self.picture.error = error
            return None

        # Remove old value
        if self.target.picture:
            self.assets_manager.delete(uid)

        # Save new value
        self.assets_manager.save(new_file.file.read(), file_id=uid, metadata={
            'filename': new_file.filename, 'content-type': new_file.type}, THUMB_SIZE=(100, 100))
        self.picture(self.assets_manager.get_image_url(uid, size='thumb'))
dataset/ETHPy150Open Net-ng/kansha/kansha/user/user_profile.py/UserForm.set_picture