def METHOD_NAME(path):
    """Returns the name of the extension in the path passed as argument.
    Args:
        path (str): path where the extension resides
    Returns:
        The extension name.
    Raises:
         ExtensionNamingError: if path does not match the expected format
             for a Spack command extension.
    """
    regexp_match = re.search(_extension_regexp, os.path.basename(os.path.normpath(path)))
    if not regexp_match:
        raise ExtensionNamingError(path)
    return regexp_match.group(1)