def get_repository_for_hook(repository_id, hosting_service_id, local_site_name, hooks_uuid=None):
 q = (Q(pk=repository_id) & Q(hosting_account__service_name=hosting_service_id))
 if hooks_uuid:
  q &= Q(hooks_uuid=hooks_uuid)
 if local_site_name:
  q &= Q(local_site__name=local_site_name)
 else:
  q &= Q(local_site__isnull=True)
 return get_object_or_404(Repository, q)

def get_repository_for_hook ( repository_id , hosting_service_id , local_site_name , hooks_uuid = None ) : q = ( Q ( pk = repository_id ) & Q ( hosting_account__service_name = hosting_service_id ) ) if hooks_uuid : q &= Q ( hooks_uuid = hooks_uuid ) if local_site_name : q &= Q ( local_site__name = local_site_name ) else : q &= Q ( local_site__isnull = True ) return get_object_or_404 ( Repository , q )
returns a repository for the given hook parameters .