Determine the script's language  extension

    >>> this_script = __file__.rstrip('c')
    >>> find_language(makepath(this_script)) == 'python'
    True

    If exts are given they restrict which extensions are allowed
    >>> find_language(makepath(this_script), ('.sh', '.txt')) is None
    True

    If there is no extension, but shebang is present, then use that
    (Expecting to find "#!" in ~/.bashrc for this test,
        but ~/.bashrc might not exist - then there's no language)

    >>> bashrc = home() / '.bashrc'
    >>> find_language(bashrc) in ('bash', None)
    True

def find_language(script, exts=None):
    """Determine the script's language  extension

    >>> this_script = __file__.rstrip('c')
    >>> find_language(makepath(this_script)) == 'python'
    True

    If exts are given they restrict which extensions are allowed
    >>> find_language(makepath(this_script), ('.sh', '.txt')) is None
    True

    If there is no extension, but shebang is present, then use that
    (Expecting to find "#!" in ~/.bashrc for this test,
        but ~/.bashrc might not exist - then there's no language)

    >>> bashrc = home() / '.bashrc'
    >>> find_language(bashrc) in ('bash', None)
    True
    """
    if not script.isfile():
        return None
    if script.ext:
        return ext_language(script.ext, exts)
    shebang = script.shebang()
    return shebang and str(shebang.name) or None