'Compute the URLs that should be resolved statically.
This recursive method is called for the war directory and every
subdirectory except the top-level WEB-INF directory. If we have arrived
at the directory <war-root>/foo/bar then dirpath will be <war-root>/foo/bar
and url_prefix will be /foo/bar.
Args:
static_urls: a list to be filled with the result, two-item tuples where
the first item is a URL and the second is a parsed <include> element.
dirpath: the path to the directory inside the war hierarchy that we have
reached at this point in the recursion.
url_prefix: the URL prefix that we have reached at this point in the
recursion.
files: the contents of the dirpath directory, minus the WEB-INF directory
if dirpath is the war directory itself.
includes_and_res: a list of two-item tuples where the first item is a
parsed <include> element and the second item is a compiled regular
expression corresponding to the path= pattern from that element.
exclude_res: a list of compiled regular expressions corresponding to the
path= patterns from <exclude> elements.'

def ComputeIncludedStaticUrls(self, static_urls, dirpath, url_prefix, files, includes_and_res, exclude_res):

    for f in files:
        path = os.path.join(dirpath, f)
        if os.path.isfile(path):
            url = (url_prefix + f)
            if (not any((exclude_re.search(url) for exclude_re in exclude_res))):
                for (include, include_re) in includes_and_res:
                    if include_re.search(url):
                        static_urls.append((url, include))
                        break
        else:
            self.ComputeIncludedStaticUrls(static_urls, path, ((url_prefix + f) + '/'), os.listdir(path), includes_and_res, exclude_res)
