def find_related_modules(package, related_name_re='<STR_LIT>',<EOL>ignore_exceptions=False):
warnings.warn('<STR_LIT>',<EOL>DeprecationWarning)<EOL>package_elements = package.rsplit("<STR_LIT:.>", <NUM_LIT:1>)<EOL>try:<EOL><INDENT>if len(package_elements) == <NUM_LIT:2>:<EOL><INDENT>pkg = __import__(package_elements[<NUM_LIT:0>], globals(), locals(), [<EOL>package_elements[<NUM_LIT:1>]])<EOL>pkg = getattr(pkg, package_elements[<NUM_LIT:1>])<EOL><DEDENT>else:<EOL><INDENT>pkg = __import__(package_elements[<NUM_LIT:0>], globals(), locals(), [])<EOL><DEDENT>pkg_path = pkg.__path__<EOL><DEDENT>except AttributeError:<EOL><INDENT>return []<EOL><DEDENT>p = re.compile(related_name_re)<EOL>modules = []<EOL>for name in find_modules(package, include_packages=True):<EOL><INDENT>if p.match(name.split('<STR_LIT:.>')[-<NUM_LIT:1>]):<EOL><INDENT>try:<EOL><INDENT>modules.append(import_string(name, silent=ignore_exceptions))<EOL><DEDENT>except Exception as e:<EOL><INDENT>if not ignore_exceptions:<EOL><INDENT>raise e<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return modules<EOL>
Find matching modules using a package and a module name pattern.