2019-09-28 20:12:49 +02:00
|
|
|
# The following comment should be removed at some point in the future.
|
|
|
|
# mypy: disallow-untyped-defs=False
|
|
|
|
|
2018-06-17 11:31:55 +02:00
|
|
|
from pip._vendor.packaging.version import parse as parse_version
|
|
|
|
|
2018-06-18 13:10:05 +02:00
|
|
|
from pip._internal.utils.models import KeyBasedCompareMixin
|
2018-12-17 12:12:36 +01:00
|
|
|
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
|
|
|
|
|
|
|
|
if MYPY_CHECK_RUNNING:
|
2019-02-22 12:17:07 +01:00
|
|
|
from pip._vendor.packaging.version import _BaseVersion
|
|
|
|
from pip._internal.models.link import Link
|
|
|
|
from typing import Any
|
2018-06-17 11:31:55 +02:00
|
|
|
|
2018-06-18 13:10:05 +02:00
|
|
|
|
|
|
|
class InstallationCandidate(KeyBasedCompareMixin):
|
2018-06-17 11:31:55 +02:00
|
|
|
"""Represents a potential "candidate" for installation.
|
|
|
|
"""
|
|
|
|
|
2019-07-20 09:11:22 +02:00
|
|
|
def __init__(self, project, version, link):
|
2018-12-17 12:12:36 +01:00
|
|
|
# type: (Any, str, Link) -> None
|
2018-06-17 11:31:55 +02:00
|
|
|
self.project = project
|
2018-12-17 12:12:36 +01:00
|
|
|
self.version = parse_version(version) # type: _BaseVersion
|
2019-07-20 09:11:22 +02:00
|
|
|
self.link = link
|
2018-06-18 13:10:05 +02:00
|
|
|
|
|
|
|
super(InstallationCandidate, self).__init__(
|
2019-07-20 09:11:22 +02:00
|
|
|
key=(self.project, self.version, self.link),
|
2018-06-18 13:10:05 +02:00
|
|
|
defining_class=InstallationCandidate
|
|
|
|
)
|
2018-06-17 11:31:55 +02:00
|
|
|
|
|
|
|
def __repr__(self):
|
2018-12-17 12:12:36 +01:00
|
|
|
# type: () -> str
|
2018-06-17 11:31:55 +02:00
|
|
|
return "<InstallationCandidate({!r}, {!r}, {!r})>".format(
|
2019-07-20 09:11:22 +02:00
|
|
|
self.project, self.version, self.link,
|
2018-06-17 11:31:55 +02:00
|
|
|
)
|
2019-06-25 11:45:18 +02:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return '{!r} candidate (version {} at {})'.format(
|
2019-07-20 09:11:22 +02:00
|
|
|
self.project, self.version, self.link,
|
2019-06-25 11:45:18 +02:00
|
|
|
)
|