def tag_photos(self, photo_entries, tags, caption):
        """Add or remove tags on a list of photos.

        Keyword arguments:
          photo_entries: List of photo entry objects.
          tags: String representation of tags in a comma separated list.
                For how tags are generated from the string,
                see googlecl.base.generate_tag_sets(). Set None to leave the tags as
                they currently are.
          caption: New caption for the photo. Set None to leave the caption as it
              is.
        """
        from gdata.media import Group, Keywords
        from atom import Summary
        if tags is not None:
            remove_set, add_set, replace_tags = googlecl.base.generate_tag_sets(
                tags)
        for photo in photo_entries:
            if tags is not None:
                if not photo.media:
                    photo.media = Group()
                if not photo.media.keywords:
                    photo.media.keywords = Keywords()
                # No point removing tags if the photo has no keywords,
                # or we're replacing the keywords.
                if photo.media.keywords.text and remove_set and not replace_tags:
                    current_tags = photo.media.keywords.text.replace(', ', ',')
                    current_set = set(current_tags.split(','))
                    photo.media.keywords.text = ','.join(
                        current_set - remove_set)

                if replace_tags or not photo.media.keywords.text:
                    photo.media.keywords.text = ','.join(add_set)
                elif add_set:
                    photo.media.keywords.text += ',' + ','.join(add_set)

            if caption is not None:
                if not photo.summary:
                    photo.summary = Summary(text=caption, summary_type='text')
                else:
                    photo.summary.text = caption

            self.UpdatePhotoMetadata(photo)
dataset/ETHPy150Open vinitkumar/googlecl/src/googlecl/picasa/service.py/PhotosServiceCL.tag_photos/original