Skip to content

Commit

Permalink
setup, pip_audit: demo spinner with progress
Browse files Browse the repository at this point in the history
  • Loading branch information
woodruffw committed Sep 16, 2021
1 parent b3fd732 commit 5931e99
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 1 addition & 2 deletions pip_audit/audit.py
Expand Up @@ -47,8 +47,7 @@ def audit(

if self._options.dry_run:
# Drain the iterator in dry-run mode.
for spec in specs:
logger.info(f"Dry run: would have audited {spec.package}")
logger.info(f"Dry run: would have audited {len(list(specs))} packages")
return {}
else:
yield from self._service.query_all(specs)
8 changes: 7 additions & 1 deletion pip_audit/cli.py
Expand Up @@ -7,6 +7,8 @@
import logging
import os

from progress.spinner import Spinner # type: ignore

from pip_audit.audit import AuditOptions, Auditor
from pip_audit.dependency_source import PipSource
from pip_audit.format import ColumnsFormat, JsonFormat, VulnerabilityFormat
Expand Down Expand Up @@ -111,4 +113,8 @@ def audit():
source = PipSource()
auditor = Auditor(service, options=AuditOptions(dry_run=args.dry_run))

print(formatter.format(auditor.audit(source)))
result = {}
for (spec, vulns) in Spinner("Auditing").iter(auditor.audit(source)):
result[spec] = vulns

print(formatter.format(result))
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -32,6 +32,7 @@
"packaging>=21.0.0",
# TODO: Remove this once 3.7 is our minimally supported version.
"dataclasses>=0.6",
"progress>=1.6",
],
extras_require={
"dev": [
Expand Down

0 comments on commit 5931e99

Please sign in to comment.