from typing import List


def get_wtfract(lstfile: str, n_phases: int) -> List[float]:
    """
    Parse .lst file to get Weighted fraction percentange of each phase.

    Parameters
    ----------
    lstfile : str
        Path to GSASII .lst file.
    n_phases : int
        Number of phases in the .lst file

    Returns
    -------
    List[int]
        Returns a List of integers for containing the weight fraction (%) for each phase.
    """
    wtfracs = []
    with open(lstfile, "r") as file:
        data = file.read()
        for i in range(1, n_phases + 1):
            try:
                wt = eval(data.split('Weight fraction')[i].split(",")[0].split(":")[-1])
            except:
                wt = -1
            wtfracs.append(wt)
    return wtfracs