def get_hooks(hook=None, default=None, app_name=None):
 def load_app_hooks(app_name=None):
  hooks = {}
  for app in ([app_name] if app_name else get_installed_apps(sort=True)):
   app = (u'frappe' if (app == u'webnotes') else app)
   try:
    app_hooks = get_module((app + u'.hooks'))
   except ImportError:
    if local.flags.in_install_app:
     pass
    print u'Could not find app "{0}"'.format(app_name)
    if (not request):
     sys.exit(1)
    raise
   for key in dir(app_hooks):
    if (not key.startswith(u'_')):
     append_hook(hooks, key, getattr(app_hooks, key))
  return hooks
 if app_name:
  hooks = _dict(load_app_hooks(app_name))
 else:
  hooks = _dict(cache().get_value(u'app_hooks', load_app_hooks))
 if hook:
  return (hooks.get(hook) or (default if (default is not None) else []))
 else:
  return hooks

def get_hooks ( hook = None , default = None , app_name = None ) : def load_app_hooks ( app_name = None ) : hooks = { } for app in ( [ app_name ] if app_name else get_installed_apps ( sort = True ) ) : app = ( u'frappe' if ( app == u'webnotes' ) else app ) try : app_hooks = get_module ( ( app + u'.hooks' ) ) except ImportError : if local . flags . in_install_app : pass print u'Could not find app "{0}"' . format ( app_name ) if ( not request ) : sys . exit ( 1 ) raise for key in dir ( app_hooks ) : if ( not key . startswith ( u'_' ) ) : append_hook ( hooks , key , getattr ( app_hooks , key ) ) return hooks if app_name : hooks = _dict ( load_app_hooks ( app_name ) ) else : hooks = _dict ( cache ( ) . get_value ( u'app_hooks' , load_app_hooks ) ) if hook : return ( hooks . get ( hook ) or ( default if ( default is not None ) else [ ] ) ) else : return hooks
returns the dict for the spec hookspath and runtime_hooks values .