in libmozdata/modules.py [0:0]
def module_from_path(path):
maxCommon = dict(module=None, directory="")
for module in data:
for directory in module["sourceDirs"]:
if (
len(os.path.commonprefix([path, directory]))
> len(os.path.commonprefix([path, maxCommon["directory"]]))
) and __match(path, directory):
maxCommon["module"] = module
maxCommon["directory"] = directory
# If we couldn't pinpoint the module, use some heuristics.
if maxCommon["module"] is None:
if (
path.endswith("configure.in")
or path.endswith("moz.build")
or path.endswith("client.mk")
or path.endswith("moz.configure")
or path.endswith("aclocal.m4")
or path.endswith("Makefile.in")
or path.startswith("python/mach")
):
return module_info("Build Config")
if path.startswith("js/"):
return module_info("JavaScript")
if path.startswith("security/"):
return module_info("security")
if path.startswith("tools/profiler/"):
return module_info("Code Analysis and Debugging Tools")
return maxCommon["module"]