def get_language()

in libmozdata/utils.py [0:0]


def get_language(path):
    """
    Detect programming language or tool
    from a filename
    """
    name = os.path.basename(path)
    extension = os.path.splitext(name)[1][1:]
    langs = {
        "Shell": ["sh"],
        "Xml": ["xml", "xst"],
        "Html": ["html", "xhtml"],
        "Css": ["css"],
        "Javascript": ["js", "jsm"],
        "Makefile": [
            "mk",
            "Makefile",
            "Makefile.am",
            "Makefile.in",
            "configure.in",
            "autoconf.mk.in",
        ],
        "C++": ["cpp", "hpp", "hh"],
        "C": ["c", "h"],
        "Java": ["java"],
        "Font": ["ttf", "ttf^headers^"],
        "Tests": ["reftest.list", "crashtests.list"],
        "Windows IDL": ["idl"],
        "Mozilla XUL": ["xul"],
        "Ini": ["ini"],
        "License": ["LICENSE"],
        "Python": ["py"],
        "moz.build": ["moz.build"],
        "Rust": ["rs"],
    }
    for lang, names in langs.items():
        if name in names or extension in names:
            return lang