def parse_changes_file()

in contrib/generate_contributor_list.py [0:0]


def parse_changes_file(file_path, versions=None):
    """
    Parse CHANGES file and return a dictionary with contributors.

    Dictionary maps contributor name to the JIRA tickets or Github pull
    requests the user has worked on.
    """
    # Maps contributor name to a list of JIRA tickets
    contributors_map = defaultdict(set)

    in_entry = False
    active_version = None
    active_tickets = []

    with open(file_path) as fp:
        for line in fp:
            line = line.strip()

            match = re.search(r"Changes with Apache Libcloud " r"(\d+\.\d+\.\d+(-\w+)?).*?$", line)

            if match:
                active_version = match.groups()[0]

            if versions and active_version not in versions:
                continue

            if line.startswith("-") or line.startswith("*)"):
                in_entry = True
                active_tickets = []

            if in_entry and line == "":
                in_entry = False

            if in_entry:
                match = re.search(r"\((.+?)\)$", line)

                if match:
                    active_tickets = match.groups()[0]
                    active_tickets = active_tickets.split(", ")
                    active_tickets = [
                        ticket
                        for ticket in active_tickets
                        if ticket.startswith("LIBCLOUD-") or ticket.startswith("GITHUB-")
                    ]

                match = re.search(r"^\[(.+?)\]$", line)

                if match:
                    contributors = match.groups()[0]
                    contributors = contributors.split(",")
                    contributors = [name.strip() for name in contributors]

                    for name in contributors:
                        name = name.title()
                        contributors_map[name].update(set(active_tickets))

    return contributors_map