from pathlib import Path
from typing import List


def get_packages(
    basedirpath: Path,
    file: str,
    search_start: str,
    search_stop: str,
    replace_strings: list,
) -> List[str]:
    """Extract packages from tox.ini as Python list"""
    with open(basedirpath.joinpath(file), "r") as fh:
        packages = []
        for line in fh:
            if search_start in line:
                break

        for line in fh:
            if search_stop in line:
                break
            new_line = line.strip()
            for replace_term in replace_strings:
                if replace_term in new_line:
                    packages.append(new_line.replace(replace_term, ""))

    return packages