from pip._vendor.packaging.utils import canonicalize_name from pip._internal.exceptions import CommandError from pip._internal.utils.typing import MYPY_CHECK_RUNNING if MYPY_CHECK_RUNNING: from typing import Optional, Set, FrozenSet class FormatControl(object): """Helper for managing formats from which a package can be installed. """ __slots__ = ["no_binary", "only_binary"] def __init__(self, no_binary=None, only_binary=None): # type: (Optional[Set[str]], Optional[Set[str]]) -> None if no_binary is None: no_binary = set() if only_binary is None: only_binary = set() self.no_binary = no_binary self.only_binary = only_binary def __eq__(self, other): # type: (object) -> bool if not isinstance(other, self.__class__): return NotImplemented if self.__slots__ != other.__slots__: return False return all( getattr(self, k) == getattr(other, k) for k in self.__slots__ ) def __ne__(self, other): # type: (object) -> bool return not self.__eq__(other) def __repr__(self): # type: () -> str return "{}({}, {})".format( self.__class__.__name__, self.no_binary, self.only_binary ) @staticmethod def handle_mutual_excludes(value, target, other): # type: (str, Set[str], Set[str]) -> None if value.startswith('-'): raise CommandError( "--no-binary / --only-binary option requires 1 argument." ) new = value.split(',') while ':all:' in new: other.clear() target.clear() target.add(':all:') del new[:new.index(':all:') + 1] # Without a none, we want to discard everything as :all: covers it if ':none:' not in new: return for name in new: if name == ':none:': target.clear() continue name = canonicalize_name(name) other.discard(name) target.add(name) def get_allowed_formats(self, canonical_name): # type: (str) -> FrozenSet[str] result = {"binary", "source"} if canonical_name in self.only_binary: result.discard('source') elif canonical_name in self.no_binary: result.discard('binary') elif ':all:' in self.only_binary: result.discard('source') elif ':all:' in self.no_binary: result.discard('binary') return frozenset(result) def disallow_binaries(self): # type: () -> None self.handle_mutual_excludes( ':all:', self.no_binary, self.only_binary, )
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
__pycache__ | Folder | 0755 |
|
|
.__init__.pyo.40009 | File | 244 B | 0644 |
|
.candidate.pyo.40009 | File | 1.79 KB | 0644 |
|
.format_control.pyo.40009 | File | 3.59 KB | 0644 |
|
.index.pyo.40009 | File | 1.45 KB | 0644 |
|
.scheme.pyo.40009 | File | 1.12 KB | 0644 |
|
.search_scope.pyo.40009 | File | 4 KB | 0644 |
|
.selection_prefs.pyo.40009 | File | 1.89 KB | 0644 |
|
.target_python.pyo.40009 | File | 3.99 KB | 0644 |
|
.wheel.pyo.40009 | File | 3.86 KB | 0644 |
|
__init__.py | File | 63 B | 0644 |
|
__init__.pyc | File | 244 B | 0644 |
|
__init__.pyo | File | 244 B | 0644 |
|
candidate.py | File | 1.17 KB | 0644 |
|
candidate.pyc | File | 1.79 KB | 0644 |
|
candidate.pyo | File | 1.79 KB | 0644 |
|
direct_url.py | File | 6.74 KB | 0644 |
|
direct_url.pyc | File | 8.8 KB | 0644 |
|
direct_url.pyo | File | 8.76 KB | 0644 |
|
format_control.py | File | 2.76 KB | 0644 |
|
format_control.pyc | File | 3.59 KB | 0644 |
|
format_control.pyo | File | 3.59 KB | 0644 |
|
index.py | File | 1.13 KB | 0644 |
|
index.pyc | File | 1.45 KB | 0644 |
|
index.pyo | File | 1.45 KB | 0644 |
|
link.py | File | 7.29 KB | 0644 |
|
link.pyc | File | 9.26 KB | 0644 |
|
link.pyo | File | 9.1 KB | 0644 |
|
scheme.py | File | 778 B | 0644 |
|
scheme.pyc | File | 1.12 KB | 0644 |
|
scheme.pyo | File | 1.12 KB | 0644 |
|
search_scope.py | File | 4.64 KB | 0644 |
|
search_scope.pyc | File | 4 KB | 0644 |
|
search_scope.pyo | File | 4 KB | 0644 |
|
selection_prefs.py | File | 2 KB | 0644 |
|
selection_prefs.pyc | File | 1.89 KB | 0644 |
|
selection_prefs.pyo | File | 1.89 KB | 0644 |
|
target_python.py | File | 3.94 KB | 0644 |
|
target_python.pyc | File | 3.99 KB | 0644 |
|
target_python.pyo | File | 3.99 KB | 0644 |
|
wheel.py | File | 2.71 KB | 0644 |
|
wheel.pyc | File | 3.86 KB | 0644 |
|
wheel.pyo | File | 3.86 KB | 0644 |
|