Make pep8 compliant

This commit is contained in:
Vineet 2014-04-05 19:56:11 +05:30
parent e215900745
commit 5637df651f
1 changed files with 9 additions and 3 deletions

View File

@ -66,6 +66,7 @@ def render_tree(pkgs, list_all):
non_top = set(flatten((x.key for x in p.requires()) non_top = set(flatten((x.key for x in p.requires())
for p in pkgs)) for p in pkgs))
top = [p for p in pkgs if p.key not in non_top] top = [p for p in pkgs if p.key not in non_top]
def aux(pkg, indent=0): def aux(pkg, indent=0):
if indent > 0: if indent > 0:
result = [' '*indent + result = [' '*indent +
@ -78,13 +79,17 @@ def render_tree(pkgs, list_all):
result += list(flatten([aux(d, indent=indent+2) result += list(flatten([aux(d, indent=indent+2)
for d in pkg_deps])) for d in pkg_deps]))
return result return result
lines = flatten([aux(p) for p in (pkgs if list_all else top)]) lines = flatten([aux(p) for p in (pkgs if list_all else top)])
return '\n'.join(lines) return '\n'.join(lines)
def main(): def main():
parser = argparse.ArgumentParser(description='Dependency tree of the installed python packages') parser = argparse.ArgumentParser(description=(
parser.add_argument('-a', '--all', action='store_true', help='list all deps at top level') 'Dependency tree of the installed python packages'
))
parser.add_argument('-a', '--all', action='store_true',
help='list all deps at top level')
parser.add_argument('-l', '--local-only', parser.add_argument('-l', '--local-only',
action='store_true', help=( action='store_true', help=(
'If in a virtualenv that has global access ' 'If in a virtualenv that has global access '
@ -92,8 +97,9 @@ def main():
)) ))
args = parser.parse_args() args = parser.parse_args()
default_skip = ['setuptools', 'pip', 'python', 'distribute'] default_skip = ['setuptools', 'pip', 'python', 'distribute']
skip = default_skip + ['pipdeptree']
packages = pip.get_installed_distributions(local_only=args.local_only, packages = pip.get_installed_distributions(local_only=args.local_only,
skip=default_skip+['pipdeptree']) skip=skip)
print(render_tree(packages, list_all=args.all)) print(render_tree(packages, list_all=args.all))
return 0 return 0