Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added Pipfile support and update pipfile using pipenv
feat #12
- Loading branch information
1 parent
0deccfc
commit 0feb077
Showing
5 changed files
with
62 additions
and
47 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -11,4 +11,4 @@ pipenv | |
ipython | ||
vulture | ||
safety | ||
pre-commit | ||
pre-commit |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# imports - module imports | ||
from pipupgrade.model.project import Project | ||
from pipupgrade.model.project import Project | ||
from pipupgrade.model.package import Package |
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,37 @@ | ||
# imports - module imports | ||
from pipupgrade import _pip, request as req | ||
|
||
def _get_pypi_info(name, raise_err = True): | ||
url = "https://pypi.org/pypi/{}/json".format(name) | ||
res = req.get(url) | ||
|
||
info = None | ||
|
||
if res.ok: | ||
data = res.json() | ||
info = data["info"] | ||
else: | ||
if raise_err: | ||
res.raise_for_status() | ||
|
||
return info | ||
|
||
class Package: | ||
def __init__(self, package): | ||
if isinstance(package, (_pip.Distribution, _pip.DistInfoDistribution, _pip.EggInfoDistribution)): | ||
self.name = package.project_name | ||
self.current_version = package.version | ||
elif isinstance(package, _pip.InstallRequirement): | ||
self.name = package.name | ||
self.current_version = package.installed_version | ||
elif isinstance(package, dict): | ||
self.name = package["name"] | ||
self.current_version = package["version"] | ||
self.latest_version = package.get("version") | ||
|
||
_pypi_info = _get_pypi_info(self.name, raise_err = False) or { } | ||
|
||
if not hasattr(self, "latest_version"): | ||
self.latest_version = _pypi_info.get("version") | ||
|
||
self.home_page = _pypi_info.get("home_page") |