'Uses app.yaml to determine the remote_api endpoint.
Args:
appyaml: A parsed app.yaml file.
Returns:
The url of the remote_api endpoint as a string, or None'

def InferRemoteApiUrl(self, appyaml):

    handlers = appyaml.handlers
    handler_suffixes = ['remote_api/handler.py', 'remote_api.handler.application']
    app_id = appyaml.application
    for handler in handlers:
        if (hasattr(handler, 'script') and handler.script):
            if any((handler.script.endswith(suffix) for suffix in handler_suffixes)):
                server = self.options.server
                url = handler.url
                if url.endswith('(/.*)?'):
                    url = url[:(-6)]
                if (server == 'appengine.google.com'):
                    return ('http://%s.appspot.com%s' % (app_id, url))
                else:
                    match = re.match(PREFIXED_BY_ADMIN_CONSOLE_RE, server)
                    if match:
                        return ('http://%s%s%s' % (app_id, match.group(1), url))
                    else:
                        return ('http://%s%s' % (server, url))
    return None
