-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support projects using pipenv and Pipfile
- Loading branch information
1 parent
f01462e
commit 52e2b57
Showing
25 changed files
with
1,708 additions
and
328 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pipenv | ||
virtualenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
"""Simplistic parsing of Pipfile dependency files | ||
This only extracts a small subset of the information present in a Pipfile, | ||
as needed for the purposes of this library. | ||
""" | ||
from utils import is_string | ||
|
||
import pytoml | ||
|
||
|
||
class PipfileRequirement(object): | ||
def __init__(self, name): | ||
self.name = name | ||
|
||
self.editable = False | ||
self.vcs = None | ||
self.vcs_uri = None | ||
self.version = None | ||
self.markers = None | ||
|
||
@classmethod | ||
def from_dict(cls, name, requirement_dict): | ||
req = cls(name) | ||
|
||
req.version = requirement_dict.get('version') | ||
req.editable = requirement_dict.get('editable', False) | ||
for vcs in ['git', 'hg', 'svn', 'bzr']: | ||
if vcs in requirement_dict: | ||
req.vcs = vcs | ||
req.vcs_uri = requirement_dict[vcs] | ||
break | ||
req.markers = requirement_dict.get('markers') | ||
|
||
return req | ||
|
||
|
||
def parse(file_contents): | ||
data = pytoml.loads(file_contents) | ||
|
||
sections = ['packages', 'dev-packages'] | ||
res = dict.fromkeys(sections) | ||
for section in sections: | ||
if section not in data: | ||
continue | ||
|
||
section_data = data[section] | ||
|
||
res[section] = [ | ||
PipfileRequirement.from_dict( | ||
name, | ||
value if not is_string(value) else {'version': value}, | ||
) | ||
for name, value in sorted(section_data.items()) | ||
] | ||
|
||
return res |
Oops, something went wrong.