from typing import Dict
from typing import Tuple
from typing import List


def parse_licenses_xml(data_root) -> Dict:
    """Parse maven licenses xml

    Args:
        data_root (xml): Parsed licenses xml

    Returns:
        [Dict]: dependency id as key, licenses url list as value
    """
    dep_data: Dict[Tuple[str, str], List[str]] = {}

    for dependency in data_root.find("dependencies"):
        dep_id = (
            dependency.find("artifactId").text, dependency.find("version").text
        )
        licenses = dependency.find("licenses")
        dep_data[dep_id] = []
        for license_data in licenses:
            license_url_text = getattr(license_data.find("url"), "text", "")
            if license_url_text.startswith('http'):
                dep_data[dep_id].append(license_url_text)
    return dep_data