Skip to content

Commit

Permalink
Merge pull request #5818 from cjerdonek/simplify-from-dist
Browse files Browse the repository at this point in the history
Add FrozenRequirement._init_args_from_dist() helper method
  • Loading branch information
cjerdonek committed Sep 30, 2018
2 parents 5dd9f5b + 309cb37 commit 356dc43
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Empty file.
16 changes: 14 additions & 2 deletions src/pip/_internal/operations/freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,13 @@ def __init__(self, name, req, editable, comments=()):
_date_re = re.compile(r'-(20\d\d\d\d\d\d)$')

@classmethod
def from_dist(cls, dist, dependency_links):
def _init_args_from_dist(cls, dist, dependency_links):
"""
Compute and return arguments (req, editable, comments) to pass to
FrozenRequirement.__init__().
This method is for use in FrozenRequirement.from_dist().
"""
location = os.path.normcase(os.path.abspath(dist.location))
comments = []
from pip._internal.vcs import vcs, get_src_requirement
Expand Down Expand Up @@ -235,7 +241,13 @@ def from_dist(cls, dist, dependency_links):
editable = True
egg_name = cls.egg_name(dist)
req = make_vcs_requirement_url(svn_location, rev, egg_name)
return cls(dist.project_name, req, editable, comments)

return (req, editable, comments)

@classmethod
def from_dist(cls, dist, dependency_links):
args = cls._init_args_from_dist(dist, dependency_links)
return cls(dist.project_name, *args)

@staticmethod
def egg_name(dist):
Expand Down

0 comments on commit 356dc43

Please sign in to comment.