Skip to content

Commit

Permalink
Refactor project package code and add VCS checks
Browse files Browse the repository at this point in the history
  • Loading branch information
techalchemy committed Oct 2, 2017
1 parent 4f4bec0 commit 6e32b6f
Showing 1 changed file with 24 additions and 32 deletions.
56 changes: 24 additions & 32 deletions pipenv/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ def path_to(self, p):

return os.sep.join([self._original_dir, p])

def _build_package_list(self, package_section):
"""Returns a list of packages for pip-tools to consume."""
ps = {}
for k, v in self.parsed_pipfile.get(package_section, {}).items():
# Skip editable VCS deps.
if hasattr(v, 'keys'):
# When a vcs url is gven without editable it only appears as a key
if is_vcs(v) or is_vcs(k):
if 'editable' not in v:
continue
else:
ps.update({k: v})
else:
if 'file' not in v and not is_vcs(v) and not is_vcs(k):
ps.update({k: v})
else:
if not is_vcs(k):
ps.update({k: v})
return ps

@property
def name(self):
if self._name is None:
Expand Down Expand Up @@ -301,7 +321,7 @@ def vcs_packages(self):
"""Returns a list of VCS packages, for not pip-tools to consume."""
ps = {}
for k, v in self.parsed_pipfile.get('packages', {}).items():
if is_vcs(v):
if is_vcs(v) or is_vcs(k):
ps.update({k: v})
return ps

Expand All @@ -310,7 +330,7 @@ def vcs_dev_packages(self):
"""Returns a list of VCS packages, for not pip-tools to consume."""
ps = {}
for k, v in self.parsed_pipfile.get('dev-packages', {}).items():
if is_vcs(v):
if is_vcs(v) or is_vcs(k):
ps.update({k: v})
return ps

Expand All @@ -324,40 +344,12 @@ def all_packages(self):
@property
def packages(self):
"""Returns a list of packages, for pip-tools to consume."""
ps = {}
for k, v in self.parsed_pipfile.get('packages', {}).items():
# Skip editable VCS deps.
if hasattr(v, 'keys'):
if is_vcs(v):
if 'editable' not in v:
continue
else:
ps.update({k: v})
else:
if 'file' not in v:
ps.update({k: v})
else:
ps.update({k: v})
return ps
return self._build_package_list('packages')

@property
def dev_packages(self):
"""Returns a list of dev-packages, for pip-tools to consume."""
ps = {}
for k, v in self.parsed_pipfile.get('dev-packages', {}).items():
# Skip editable VCS deps.
if hasattr(v, 'keys'):
if is_vcs(v):
if 'editable' not in v:
continue
else:
ps.update({k: v})
else:
if 'file' not in v:
ps.update({k: v})
else:
ps.update({k: v})
return ps
return self._build_package_list('dev-packages')

def touch_pipfile(self):
"""Simply touches the Pipfile, for later use."""
Expand Down

0 comments on commit 6e32b6f

Please sign in to comment.