Skip to content

Commit

Permalink
Merge branch 'release-0.0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
sinoroc committed Oct 24, 2019
2 parents b1ff164 + 878e703 commit b1f71d6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

.. Keep the current version number on line number 5
0.0.4
=====

2019-10-24

* Sort output alphabetically


0.0.3
=====

Expand Down
24 changes: 15 additions & 9 deletions src/deptree/_pkg_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def _display_missing_reverse(requirement, depth):
)


def _display(requirement, chain):
def _display(distributions, requirement, chain):
depth = len(chain)
try:
distribution = pkg_resources.get_distribution(requirement)
Expand All @@ -85,8 +85,16 @@ def _display(requirement, chain):
except pkg_resources.UnknownExtra as exception:
print(exception)
else:
for dependency_requirement in dependencies:
sorted_dependency_keys = sorted([
dependency.key
for dependency
in dependencies
])
all_deps = distributions[distribution.key]['dependencies']
for dependency_key in sorted_dependency_keys:
dependency_requirement = all_deps[dependency_key]
_display(
distributions,
dependency_requirement,
chain + [distribution.key],
)
Expand All @@ -112,7 +120,7 @@ def _display_reverse(distributions, project_req, dependency_req, chain):
else:
_display_good(project_dist, '', depth)
dependents = distributions[project_dist.key]['dependents']
for (dependent_key, dependent_req) in dependents.items():
for (dependent_key, dependent_req) in sorted(dependents.items()):
_display_reverse(
distributions,
dependent_key,
Expand Down Expand Up @@ -148,7 +156,7 @@ def _select_top_level(distributions):
selection = [
key
for (key, info)
in distributions.items()
in sorted(distributions.items())
if not info['dependents']
]
return selection
Expand All @@ -158,17 +166,15 @@ def _select_bottom_level(distributions):
selection = [
key
for (key, info)
in distributions.items()
in sorted(distributions.items())
if info['installed'] and not info['dependencies']
]
return selection


def main(selection, reverse):
""" Main function """
distributions = None
if not selection or reverse:
distributions = _discover_distributions()
distributions = _discover_distributions()
if not selection:
if reverse:
selection = _select_bottom_level(distributions)
Expand All @@ -179,7 +185,7 @@ def main(selection, reverse):
if reverse:
_display_reverse(distributions, requirement, None, [])
else:
_display(requirement, [])
_display(distributions, requirement, [])


# EOF

0 comments on commit b1f71d6

Please sign in to comment.