<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _GetAppYamlHostname(application_path, open_func=open):
 """Build the hostname for this app based on the name in app.yaml. Args: application_path: A string with the path to the AppEngine application. This should be the directory containing the app.yaml file. open_func: Function to call to open a file. Used to override the default open function in unit tests. Returns: A hostname, usually in the form of "myapp.appspot.com", based on the application name in the app.yaml file. If the file can't be found or there's a problem building the name, this will return None. """

  try:
    app_yaml_file = open_func(os.path.join(application_path or '.', 'app.yaml'))
    config = yaml.safe_load(app_yaml_file.read())
  except IOError:
    # Couldn't open/read app.yaml.
    return None

  application = config.get('application')
  if not application:
    return None

  if ':' in application:
    # Don't try to deal with alternate domains.
    return None

  # If there's a prefix ending in a '~', strip it.
  tilde_index = application.rfind('~')
  if tilde_index >= 0:
    application = application[tilde_index + 1:]
    if not application:
      return None

  return '%s.appspot.com' % application