import pkg_resources


def freeze(lines):
    """Parse lines from freeze file into a dict.

    Where k:v is project_name:specifier.
    """
    freeze = dict()

    for line in lines:
        try:
            req = pkg_resources.Requirement.parse(line)
            freeze[req.project_name] = req.specifier
        except ValueError:
            # not a valid requirement, can be a comment, blank line etc
            continue
    return freeze