def replace_static_urls(text, data_directory=None, course_id=None, static_asset_path=''):
 def replace_static_url(original, prefix, quote, rest):
  '\n        Replace a single matched url.\n        '
  if rest.endswith('?raw'):
   return original
  if (settings.DEBUG and finders.find(rest, True)):
   return original
  elif ((not static_asset_path) and course_id):
   exists_in_staticfiles_storage = False
   try:
    exists_in_staticfiles_storage = staticfiles_storage.exists(rest)
   except Exception as err:
    log.warning("staticfiles_storage couldn't find path {0}: {1}".format(rest, str(err)))
   if exists_in_staticfiles_storage:
    url = staticfiles_storage.url(rest)
   else:
    base_url = AssetBaseUrlConfig.get_base_url()
    excluded_exts = AssetExcludedExtensionsConfig.get_excluded_extensions()
    url = StaticContent.get_canonicalized_asset_path(course_id, rest, base_url, excluded_exts)
    if (AssetLocator.CANONICAL_NAMESPACE in url):
     url = url.replace('block@', 'block/', 1)
  else:
   course_path = '/'.join(((static_asset_path or data_directory), rest))
   try:
    if staticfiles_storage.exists(rest):
     url = staticfiles_storage.url(rest)
    else:
     url = staticfiles_storage.url(course_path)
   except Exception as err:
    log.warning("staticfiles_storage couldn't find path {0}: {1}".format(rest, str(err)))
    url = ''.join([prefix, course_path])
  return ''.join([quote, url, quote])
 return process_static_urls(text, replace_static_url, data_dir=(static_asset_path or data_directory))

def replace_static_urls ( text , data_directory = None , course_id = None , static_asset_path = '' ) : def replace_static_url ( original , prefix , quote , rest ) : if rest . endswith ( '?raw' ) : return original if ( settings . DEBUG and finders . find ( rest , True ) ) : return original elif ( ( not static_asset_path ) and course_id ) : exists_in_staticfiles_storage = False try : exists_in_staticfiles_storage = staticfiles_storage . exists ( rest ) except Exception as err : log . warning ( "staticfiles_storage couldn't find path {0}: {1}" . format ( rest , str ( err ) ) ) if exists_in_staticfiles_storage : url = staticfiles_storage . url ( rest ) else : base_url = AssetBaseUrlConfig . get_base_url ( ) excluded_exts = AssetExcludedExtensionsConfig . get_excluded_extensions ( ) url = StaticContent . get_canonicalized_asset_path ( course_id , rest , base_url , excluded_exts ) if ( AssetLocator . CANONICAL_NAMESPACE in url ) : url = url . replace ( 'block@' , 'block/' , 1 ) else : course_path = '/' . join ( ( ( static_asset_path or data_directory ) , rest ) ) try : if staticfiles_storage . exists ( rest ) : url = staticfiles_storage . url ( rest ) else : url = staticfiles_storage . url ( course_path ) except Exception as err : log . warning ( "staticfiles_storage couldn't find path {0}: {1}" . format ( rest , str ( err ) ) ) url = '' . join ( [ prefix , course_path ] ) return '' . join ( [ quote , url , quote ] ) return process_static_urls ( text , replace_static_url , data_dir = ( static_asset_path or data_directory ) )
updates the supplied module with a new get_html function that wraps the old get_html function and substitutes urls of the form /static/ .