#NEWLINE# def resolve_app( app_label , strict = False ) : #NEWLINE# #INDENT# "Return the `modules` module of the given `app_label` if it is\n    installed.  Otherwise return either the :term:`dummy module` for\n    `app_label` if it exists, or `None`.\n\n    If the optional second argument `strict` is `True`, raise\n    ImportError if the app is not installed.\n    \n    This function is designed for use in models modules and available\n    through the shortcut ``dd.resolve_app``.\n    \n    For example, instead of writing::\n    \n        from lino.modlib.sales import models as sales\n        \n    it is recommended to write::\n        \n        sales = dd.resolve_app('sales')\n        \n    because it makes your code usable (1) in applications that don't\n    have the 'sales' module installed and (2) in applications who have\n    another implementation of the `sales` module\n    (e.g. :mod:`lino.modlib.auto.sales`)\n\n    " #NEWLINE# for app_name in settings . INSTALLED_APPS : #NEWLINE# #INDENT# if ( ( app_name == app_label ) or app_name . endswith ( ( '.' + app_label ) ) ) : #NEWLINE# #INDENT# return import_module ( '.models' , strict ) #NEWLINE# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# return import_module ( ( 'lino.modlib.%s.dummy' % app_label ) ) #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# if strict : #NEWLINE# #INDENT# raise ImportError ( ( 'No app_label %r in %s' % ( app_label , settings . INSTALLED_APPS ) ) )