code: def attach_attachment(self, analysis, attachment):
          
          if not attachment:
              return
          if isinstance(attachment, list):
              for attach in attachment:
                  self.attach_attachment(analysis, attach)
              return
          # current attachments
          an_atts = analysis.getAttachment()
          atts_filenames = [att.getAttachmentFile().filename for att in an_atts]
          if attachment.getAttachmentFile().filename not in atts_filenames:
              an_atts.append(attachment)
              logger.info(
                  "Attaching %s to %s" % (attachment.UID(), analysis))
              analysis.setAttachment([att.UID() for att in an_atts])
              analysis.reindexObject()
          else:
              self.warn("Attachment %s was not linked to analysis %s" %
                        (attachment.UID(), analysis))
docs: Attach a file or a given set of files to an analysis
  
          :param analysis: analysis where the files are to be attached
          :param attachment: files to be attached. This can be either a
          single file or a list of files
          :return: None