def GenerateAppleSUSCatalogs(track=None, tracks=None, delay=0):
  """Generates Apple SUS catalogs for a given track, set of tracks, or all.
  Note: this generates tracks for all os_versions on the given track/tracks.

  Args:
    track: string track to generate catalog for. OR,
    tracks: list of string tracks.
    delay: int. if > 0, defer generating the catalogs by this many seconds.
  """
  if track and tracks:
    raise ValueError('only one of track and tracks is allowed')
  elif not tracks and not track:
    tracks = common.TRACKS
  elif track:
    tracks = [track]

  for track in tracks:
    for os_version in OS_VERSIONS:
      if delay:
        now_str = datetime.datetime.utcnow().strftime('%Y-%m-%d-%H-%M-%S')
        deferred_name = 'gen-applesus-catalog-%s-%s-%s' % (
            os_version, track, now_str)
        deferred_name = re.sub(r'[^\w-]', '', deferred_name)
        try:
          deferred.defer(
              GenerateAppleSUSCatalog, os_version, track,
              _countdown=delay, _name=deferred_name)
        except taskqueue.TaskAlreadyExistsError:
          logging.info('Skipping duplicate Apple SUS Catalog generation task.')
      else:
        GenerateAppleSUSCatalog(os_version, track)

  if delay:
    now_str = datetime.datetime.utcnow().strftime('%Y-%m-%d-%H-%M-%S')
    deferred_name = 'gen-sus-metadata-catalog-%s' % now_str
    deferred_name = re.sub(r'[^\w-]', '', deferred_name)
    try:
      deferred.defer(
          GenerateAppleSUSMetadataCatalog, _name=deferred_name)
    except taskqueue.TaskAlreadyExistsError:
      logging.info('Skipping duplicate Apple SUS Catalog generation task.')
  else:
    GenerateAppleSUSMetadataCatalog()
dataset/ETHPy150Open google/simian/src/simian/mac/common/applesus.py/GenerateAppleSUSCatalogs/original