-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there any desire for a "pretty print" output of "pip list"? #3651
Comments
Some comments:
As for the option name, maybe add BTW, a simple adaptive tabulation function isn't that hard: def tabulate(vals):
assert len(vals) > 0
sizes = [0] * len(vals[0])
for row in vals:
sizes = [max(s, len(str(c))) for s, c in zip(sizes, row)]
result = []
for row in vals:
display = " ".join([str(c).ljust(s) for s, c in zip(sizes, row)])
result.append(display)
return result |
So I'll go ahead and start working on it with the following changes:
Question: |
Personally, I see the adaptive width version as just as easy to parse (in Python, use split(), in shell use awk). And much easier to parse than the current output, to the extent that if it weren't for backward compatibility, I'd personally prefer the tabular output as the default. With a |
Now that I think about it more, you're right: column formatting will actually be easier to parse via And yeah, 3 options just for pretty-printing is quite a lot. I'll leave out |
I think the proposed format is superior to the old format in basically every way except that the old format currently exists so I'd like to push back on @pfmoore's first point a minute, about the only time I can imagine the old format being preferable is if there is already a script parsing that output so what if instead of just leaving the old format as the default we phased in the new format and deprecated the old? So we'd first add |
Another thing I wonder, do we really need the |
Well I'm happy to whip up whatever gets decided. Deprecation Do you have any proposal for a timeline?
Removing this option will also simplify the code a little bit. Here's an example of how it currently looks:
|
I agree with pretty much everything @dstufft said. The @dougthor42 That example looks fantastic. |
@dougthor42 We have a deprecation process and utilities already, you'll just need to do something like: import warnings
from pip.utils.deprecation import RemovedInPip10Warning
if options.no_columns:
warnings.warn(RemovedInPip10Warning, "Some message about how this is going to be removed") From there we'll manage walking it along the deprecation process. |
Just FYI, PR #3654 is ready for review. |
Description:
Is there any desire for a "pretty print" output of
pip list
?I'm willing and able to do the work for this, but I'd rather not bother if it's not something people are interested in.
What I've run:
N/A
Comments:
When running
pip list
, the output looks like so:I thought that it might be nice to have the option to arrange the items into columns:
Implementation
In order to implement this, I would modify
list.py
, specifically theoutput_package
andrun_outdated
methods ofListCommand
. The modifications would be to add format specifiers to the return values (tentative):'%-40s %-15s %7s'
'%-35s %-15s %s'
I would of course add the ``--pretty
option to
ListCommand.init()` and update documentation to reflect the change. To maintain backwards compatibility, the --pretty option would default to false, so there will be no change in behavior for default commands.Potential issues
The text was updated successfully, but these errors were encountered: