def find_best_app(module):
 from . import Flask
 for attr_name in ('app', 'application'):
  app = getattr(module, attr_name, None)
  if ((app is not None) and isinstance(app, Flask)):
   return app
 matches = [v for (k, v) in iteritems(module.__dict__) if isinstance(v, Flask)]
 if (len(matches) == 1):
  return matches[0]
 raise NoAppException(('Failed to find application in module "%s".  Are you sure it contains a Flask application?  Maybe you wrapped it in a WSGI middleware or you are using a factory function.' % module.__name__))

def find_best_app ( module ) : from . import Flask for attr_name in ( 'app' , 'application' ) : app = getattr ( module , attr_name , None ) if ( ( app is not None ) and isinstance ( app , Flask ) ) : return app matches = [ v for ( k , v ) in iteritems ( module . __dict__ ) if isinstance ( v , Flask ) ] if ( len ( matches ) == 1 ) : return matches [ 0 ] raise NoAppException ( ( 'Failed to find application in module "%s".  Are you sure it contains a Flask application?  Maybe you wrapped it in a WSGI middleware or you are using a factory function.' % module . __name__ ) )
given a module instance this tries to find the best possible application in the module or raises an exception .