def delete_versions(project, version_data):
 current_versions = []
 if ('tags' in version_data):
  for version in version_data['tags']:
   current_versions.append(version['identifier'])
 if ('branches' in version_data):
  for version in version_data['branches']:
   current_versions.append(version['identifier'])
 to_delete_qs = project.versions.all()
 to_delete_qs = to_delete_qs.exclude(identifier__in=current_versions)
 to_delete_qs = to_delete_qs.exclude(uploaded=True)
 to_delete_qs = to_delete_qs.exclude(active=True)
 to_delete_qs = to_delete_qs.exclude(slug__in=NON_REPOSITORY_VERSIONS)
 if to_delete_qs.count():
  ret_val = {obj.slug for obj in to_delete_qs}
  log.info(('(Sync Versions) Deleted Versions: [%s]' % ' '.join(ret_val)))
  to_delete_qs.delete()
  return ret_val
 else:
  return set()

def delete_versions ( project , version_data ) : current_versions = [ ] if ( 'tags' in version_data ) : for version in version_data [ 'tags' ] : current_versions . append ( version [ 'identifier' ] ) if ( 'branches' in version_data ) : for version in version_data [ 'branches' ] : current_versions . append ( version [ 'identifier' ] ) to_delete_qs = project . versions . all ( ) to_delete_qs = to_delete_qs . exclude ( identifier__in = current_versions ) to_delete_qs = to_delete_qs . exclude ( uploaded = True ) to_delete_qs = to_delete_qs . exclude ( active = True ) to_delete_qs = to_delete_qs . exclude ( slug__in = NON_REPOSITORY_VERSIONS ) if to_delete_qs . count ( ) : ret_val = { obj . slug for obj in to_delete_qs } log . info ( ( '(Sync Versions) Deleted Versions: [%s]' % ' ' . join ( ret_val ) ) ) to_delete_qs . delete ( ) return ret_val else : return set ( )
delete all versions not in the current repo .