Skip to content

Commit 0df5afb

Browse files
committed
only output good packages in graph --json
Signed-off-by: Kenneth Reitz <[email protected]>
1 parent ce091ec commit 0df5afb

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

pipenv/cli.py

+19-17
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
# Packages that should be ignored later.
6868
BAD_PACKAGES = (
6969
'setuptools', 'pip', 'wheel', 'six', 'packaging', 'distribute'
70-
'pyparsing', 'appdirs', 'pipenv'
70+
'pyparsing', 'appdirs',
7171
)
7272

7373
# Are we using the default Python?
@@ -984,7 +984,7 @@ def do_lock(verbose=False, system=False, clear=False):
984984
# Run the PEP 508 checker in the virtualenv, add it to the lockfile.
985985
cmd = '"{0}" {1}'.format(which('python', allow_global=system), shellquote(pep508checker.__file__.rstrip('cdo')))
986986
c = delegator.run(cmd)
987-
lockfile['_meta']['host-environment-markers'] = json.loads(c.out)
987+
lockfile['_meta']['host-environment-markers'] = simplejson.loads(c.out)
988988

989989
# Write out the lockfile.
990990
with open(project.lockfile_location, 'w') as f:
@@ -1950,9 +1950,6 @@ def graph(bare=False, json=False):
19501950
)
19511951
sys.exit(1)
19521952

1953-
if json:
1954-
bare = True
1955-
19561953
j = '--json' if json else ''
19571954

19581955
cmd = '"{0}" {1} {2}'.format(
@@ -1967,23 +1964,28 @@ def graph(bare=False, json=False):
19671964
if not bare:
19681965

19691966
if json:
1970-
data = simplejson.loads(c.out)
1971-
print(data)
1967+
data = []
1968+
for d in simplejson.loads(c.out):
19721969

1970+
if d['package']['key'] not in BAD_PACKAGES:
1971+
data.append(d)
19731972

1974-
for line in c.out.split('\n'):
1973+
click.echo(simplejson.dumps(data, indent=4))
1974+
sys.exit(0)
1975+
else:
1976+
for line in c.out.split('\n'):
19751977

1976-
# Ignore bad packages.
1977-
if line.split('==')[0] in BAD_PACKAGES:
1978-
continue
1978+
# Ignore bad packages.
1979+
if line.split('==')[0] in BAD_PACKAGES:
1980+
continue
19791981

1980-
# Bold top-level packages.
1981-
if not line.startswith(' '):
1982-
click.echo(crayons.white(line, bold=True))
1982+
# Bold top-level packages.
1983+
if not line.startswith(' '):
1984+
click.echo(crayons.white(line, bold=True))
19831985

1984-
# Echo the rest.
1985-
else:
1986-
click.echo(crayons.white(line, bold=False))
1986+
# Echo the rest.
1987+
else:
1988+
click.echo(crayons.white(line, bold=False))
19871989
else:
19881990
click.echo(c.out)
19891991

0 commit comments

Comments
 (0)