def ParseAndReturnIncludePaths(appinfo_file, open_fn=open):
 try:
  appinfo_path = appinfo_file.name
  if (not os.path.isfile(appinfo_path)):
   raise Exception(('Name defined by appinfo_file does not appear to be a valid file: %s' % appinfo_path))
 except AttributeError:
  raise Exception('File object passed to ParseAndMerge does not define attribute "name" as as full file path.')
 appyaml = appinfo.LoadSingleAppInfo(appinfo_file)
 (appyaml, include_paths) = _MergeBuiltinsIncludes(appinfo_path, appyaml, open_fn)
 if (not appyaml.handlers):
  if appyaml.IsVm():
   appyaml.handlers = [appinfo.URLMap(url='.*', script='PLACEHOLDER')]
  else:
   raise appinfo_errors.MissingURLMapping('No URLMap entries found in application configuration')
 if (len(appyaml.handlers) > appinfo.MAX_URL_MAPS):
  raise appinfo_errors.TooManyURLMappings(('Found more than %d URLMap entries in application configuration' % appinfo.MAX_URL_MAPS))
 if ((appyaml.runtime == 'python27') and appyaml.threadsafe):
  for handler in appyaml.handlers:
   if (handler.script and (handler.script.endswith('.py') or ('/' in handler.script))):
    raise appinfo_errors.ThreadsafeWithCgiHandler(('Threadsafe cannot be enabled with CGI handler: %s' % handler.script))
 return (appyaml, include_paths)

def ParseAndReturnIncludePaths ( appinfo_file , open_fn = open ) : try : appinfo_path = appinfo_file . name if ( not os . path . isfile ( appinfo_path ) ) : raise Exception ( ( 'Name defined by appinfo_file does not appear to be a valid file: %s' % appinfo_path ) ) except AttributeError : raise Exception ( 'File object passed to ParseAndMerge does not define attribute "name" as as full file path.' ) appyaml = appinfo . LoadSingleAppInfo ( appinfo_file ) ( appyaml , include_paths ) = _MergeBuiltinsIncludes ( appinfo_path , appyaml , open_fn ) if ( not appyaml . handlers ) : if appyaml . IsVm ( ) : appyaml . handlers = [ appinfo . URLMap ( url = '.*' , script = 'PLACEHOLDER' ) ] else : raise appinfo_errors . MissingURLMapping ( 'No URLMap entries found in application configuration' ) if ( len ( appyaml . handlers ) > appinfo . MAX_URL_MAPS ) : raise appinfo_errors . TooManyURLMappings ( ( 'Found more than %d URLMap entries in application configuration' % appinfo . MAX_URL_MAPS ) ) if ( ( appyaml . runtime == 'python27' ) and appyaml . threadsafe ) : for handler in appyaml . handlers : if ( handler . script and ( handler . script . endswith ( '.py' ) or ( '/' in handler . script ) ) ) : raise appinfo_errors . ThreadsafeWithCgiHandler ( ( 'Threadsafe cannot be enabled with CGI handler: %s' % handler . script ) ) return ( appyaml , include_paths )
parse an appyaml file and merge referenced includes and builtins .