def _GetAppYamlHostname(application_path, open_func=open):
try:<EOL><INDENT>app_yaml_file = open_func(os.path.join(application_path or '<STR_LIT:.>', '<STR_LIT>'))<EOL>config = yaml.safe_load(app_yaml_file.read())<EOL><DEDENT>except IOError:<EOL><INDENT>return None<EOL><DEDENT>application = config.get('<STR_LIT>')<EOL>if not application:<EOL><INDENT>return None<EOL><DEDENT>if '<STR_LIT::>' in application:<EOL><INDENT>return None<EOL><DEDENT>tilde_index = application.rfind('<STR_LIT>')<EOL>if tilde_index >= <NUM_LIT:0>:<EOL><INDENT>application = application[tilde_index + <NUM_LIT:1>:]<EOL>if not application:<EOL><INDENT>return None<EOL><DEDENT><DEDENT>return '<STR_LIT>' % application<EOL>
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.