Skip to content

Commit 764e468

Browse files
committed
refactor the requirements file parsing
two major changes: 1) re-use the optparse options in pip.cmdoptions instead of maintaining a custom parser 2) as a result of #1, simplify the call stack from: parse_requirements -> parse_content -> parse_line to: parse_requirements -> process_line beyond #1/#2, minor cosmetics and adjusting the tests to match
1 parent 0e1704a commit 764e468

File tree

4 files changed

+249
-360
lines changed

4 files changed

+249
-360
lines changed

pip/cmdoptions.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,16 @@ def editable():
434434
help="Don't periodically check PyPI to determine whether a new version "
435435
"of pip is available for download. Implied with --no-index.")
436436

437+
# Deprecated, Remove later
438+
always_unzip = partial(
439+
Option,
440+
'-Z', '--always-unzip',
441+
dest='always_unzip',
442+
action='store_true',
443+
help=SUPPRESS_HELP,
444+
)
445+
446+
437447
##########
438448
# groups #
439449
##########

pip/exceptions.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,21 @@ class DistributionNotFound(InstallationError):
1919

2020

2121
class RequirementsFileParseError(PipError):
22-
"""Raised when an invalid state is encountered during requirement file
23-
parsing."""
22+
"""Raised when a general error occurs parsing a requirements file line."""
23+
24+
25+
class ReqFileOnlyOneReqPerLineError(PipError):
26+
"""Raised when more than one requirement is found on a line in a requirements
27+
file."""
28+
29+
30+
class ReqFileOnleOneOptionPerLineError(PipError):
31+
"""Raised when an option is not allowed in a requirements file."""
32+
33+
34+
class ReqFileOptionNotAllowedWithReqError(PipError):
35+
"""Raised when an option is not allowed on a requirement line in a requirements
36+
file."""
2437

2538

2639
class BestVersionAlreadyInstalled(PipError):

0 commit comments

Comments
 (0)