Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
news
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sartika Aritonang
news
Commits
8359eceb
Commit
8359eceb
authored
May 29, 2020
by
Sartika Aritonang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
f23a8556
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
0 deletions
+84
-0
format_control.py
.../Lib/site-packages/pip/_internal/models/format_control.py
+84
-0
No files found.
stbi/Lib/site-packages/pip/_internal/models/format_control.py
0 → 100644
View file @
8359eceb
# The following comment should be removed at some point in the future.
# mypy: strict-optional=False
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.
"""
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
return
self
.
__dict__
==
other
.
__dict__
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, Optional[Set[str]], Optional[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
,
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment