Skip to content

Commit

Permalink
refactor the requirements file parsing
Browse files Browse the repository at this point in the history
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
  • Loading branch information
qwcode committed Apr 17, 2015
1 parent 0e1704a commit 764e468
Show file tree
Hide file tree
Showing 4 changed files with 249 additions and 360 deletions.
10 changes: 10 additions & 0 deletions pip/cmdoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,16 @@ def editable():
help="Don't periodically check PyPI to determine whether a new version "
"of pip is available for download. Implied with --no-index.")

# Deprecated, Remove later
always_unzip = partial(
Option,
'-Z', '--always-unzip',
dest='always_unzip',
action='store_true',
help=SUPPRESS_HELP,
)


##########
# groups #
##########
Expand Down
17 changes: 15 additions & 2 deletions pip/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,21 @@ class DistributionNotFound(InstallationError):


class RequirementsFileParseError(PipError):
"""Raised when an invalid state is encountered during requirement file
parsing."""
"""Raised when a general error occurs parsing a requirements file line."""


class ReqFileOnlyOneReqPerLineError(PipError):
"""Raised when more than one requirement is found on a line in a requirements
file."""


class ReqFileOnleOneOptionPerLineError(PipError):
"""Raised when an option is not allowed in a requirements file."""


class ReqFileOptionNotAllowedWithReqError(PipError):
"""Raised when an option is not allowed on a requirement line in a requirements
file."""


class BestVersionAlreadyInstalled(PipError):
Expand Down
Loading

0 comments on commit 764e468

Please sign in to comment.