code: def _granule_identifier_to_xml_name(granule_identifier):
      
      # Replace "MSI" with "MTD".
      changed_item_type = re.sub("_MSI_", "_MTD_", granule_identifier)
      # Split string up by underscores.
      split_by_underscores = changed_item_type.split("_")
      del split_by_underscores[-1]
      cleaned = str()
      # Stitch string list together, adding the previously removed underscores.
      for i in split_by_underscores:
          cleaned += (i + "_")
      # Remove last underscore and append XML file extension.
      out_xml = cleaned[:-1] + ".xml"
  
      return out_xml
docs: Very ugly way to convert the granule identifier.
  
      e.g.
      From
      Granule Identifier:
      S2A_OPER_MSI_L1C_TL_SGS__20150817T131818_A000792_T28QBG_N01.03
      To
      Granule Metadata XML name:
      S2A_OPER_MTD_L1C_TL_SGS__20150817T131818_A000792_T28QBG.xml