def import_related_module(package, pkg_path, related_name,<EOL>ignore_exceptions=False):
try:<EOL><INDENT>imp.find_module(related_name, pkg_path)<EOL><DEDENT>except ImportError:<EOL><INDENT>return<EOL><DEDENT>try:<EOL><INDENT>return getattr(<EOL>__import__('<STR_LIT:%s>' % (package), globals(), locals(), [related_name]),<EOL>related_name<EOL>)<EOL><DEDENT>except Exception as e:<EOL><INDENT>if ignore_exceptions:<EOL><INDENT>current_app.logger.exception(<EOL>'<STR_LIT>'.format(package)<EOL>)<EOL><DEDENT>else:<EOL><INDENT>raise e<EOL><DEDENT><DEDENT>
Import module from given path.