def urlmap(patterns):
for pattern in patterns:<EOL><INDENT>group = getattr(pattern, '<STR_LIT>', None)<EOL>if group is None:<EOL><INDENT>group = getattr(pattern, '<STR_LIT>', None)<EOL><DEDENT>path = '<STR_LIT:/>' + get_pattern(pattern).lstrip('<STR_LIT>').rstrip('<STR_LIT:$>')<EOL>if isinstance(pattern, PATTERNS):<EOL><INDENT>yield (group, pattern.name), path<EOL><DEDENT>elif isinstance(pattern, RESOLVERS):<EOL><INDENT>subpatterns = pattern.url_patterns<EOL>for (_, name), subpath in urlmap(subpatterns):<EOL><INDENT>yield (group, name), path.rstrip('<STR_LIT:/>') + subpath<EOL><DEDENT><DEDENT><DEDENT>
Recursively build a map of (group, name) => url patterns.

    Group is either the resolver namespace or app name for the url config.

    The urls are joined with any prefixes, and cleaned up of extraneous regex
    specific syntax.