def get_request_or_stub():
 request = crum.get_current_request()
 if (request is None):
  log.warning('Could not retrieve the current request. A stub request will be created instead using settings.SITE_NAME. This should be used *only* in test cases, never in production!')
  full_url = 'http://{site_name}'.format(site_name=settings.SITE_NAME)
  parsed_url = urlparse(full_url)
  return RequestFactory(SERVER_NAME=parsed_url.hostname, SERVER_PORT=(parsed_url.port or 80)).get('/')
 else:
  return request

def get_request_or_stub ( ) : request = crum . get_current_request ( ) if ( request is None ) : log . warning ( 'Could not retrieve the current request. A stub request will be created instead using settings.SITE_NAME. This should be used *only* in test cases, never in production!' ) full_url = 'http://{site_name}' . format ( site_name = settings . SITE_NAME ) parsed_url = urlparse ( full_url ) return RequestFactory ( SERVER_NAME = parsed_url . hostname , SERVER_PORT = ( parsed_url . port or 80 ) ) . get ( '/' ) else : return request
return the current request or a stub request .