from typing import Iterable
from typing import Tuple
import re


def _read_gitmodules_file_content(
        gitmodules_file_content: str) -> Iterable[Tuple[str, str, str]]:
    """Some basic regex extractions to parse content of .gitmodules file
    """
    name_regex = r'\[submodule "([a-zA-Z0-9\.\-/_]+)"\]'
    path_regex = r'path ?= ?([a-zA-Z0-9\.\-/_]+)'
    url_regex = r'url ?= ?([a-zA-Z0-9\.\-/_:@]+)'
    names = re.findall(name_regex, gitmodules_file_content)
    paths = re.findall(path_regex, gitmodules_file_content)
    urls = re.findall(url_regex, gitmodules_file_content)
    if not (len(names) == len(paths) == len(urls)):
        raise RuntimeError('Failed parsing the .gitmodules content')
    return zip(names, urls, paths)