This repository has been archived by the owner on Jan 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
116 additions
and
29 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
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
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,54 @@ | ||
# built-in | ||
from argparse import ArgumentParser | ||
from pathlib import Path | ||
|
||
# app | ||
from ..config import builders | ||
from ..converters import InstalledConverter | ||
from ..repositories import WareHouseRepo | ||
from ..venvs import VEnvs | ||
from .base import BaseCommand | ||
|
||
|
||
class PackageListCommand(BaseCommand): | ||
@classmethod | ||
def get_parser(cls): | ||
parser = ArgumentParser( | ||
prog='dephell package list', | ||
description='Show all installed packages', | ||
) | ||
builders.build_config(parser) | ||
builders.build_output(parser) | ||
builders.build_api(parser) | ||
builders.build_other(parser) | ||
return parser | ||
|
||
def __call__(self): | ||
venvs = VEnvs(path=self.config['venv']) | ||
venv = venvs.get(Path(self.config['project']), env=self.config.env) | ||
path = None | ||
if venv.exists(): | ||
path = venv.lib_path | ||
else: | ||
self.logger.warning('venv not found, package version will be shown for global python lib') | ||
|
||
converter = InstalledConverter() | ||
root = converter.load(path) | ||
|
||
repo = WareHouseRepo() | ||
data = [] | ||
for dep in root.dependencies: | ||
releases = repo.get_releases(dep) | ||
data.append(dict( | ||
name=dep.name, | ||
version=dict( | ||
latest=str(releases[0].version), | ||
installed=str(dep.constraint).lstrip('='), | ||
), | ||
description=dep.description, | ||
|
||
license=getattr(dep.license, 'id', dep.license), | ||
links=dep.links, | ||
authors=[str(author) for author in dep.authors], | ||
)) | ||
print(self.get_value(data=data, key=self.config.get('filter'))) |
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