Skip to content

Conversation

@AA-Turner
Copy link
Member

Currently, py list --format csv produces very sparse output. This PR modifies it to print the 'core' information for each line, alongside the 'expanded' data. This will help with use of the CSV data in e.g. Excel, for sorting & filtering etc.

I would be in favour of ensuring the CSV output is always dense, which would require dropping one or both of the alias / run-for list-tables, but these may be useful enough to keep.

Current:

id,display-name,sort-version,company,tag,default,__any-platform,prefix,run-for.tag,run-for.target,run-for.windowed,alias.name,alias.target,alias.windowed,url,source,hash
pythoncore-3.13-64,Python 3.13.2,3.13.2,PythonCore,3.13-64,,,C:\Users\Adam\AppData\Local\Python\pythoncore-3.13-64,,,,,,,https://api.nuget.org/v3-flatcontainer/python/3.13.2/python.3.13.2.nupkg,file:///C:/Program Files/WindowsApps/PythonSoftwareFoundation.PythonManager_0.1.0.172_x64__7qnp2ymwnadz2/./bundled/index.json,
,,,,,,,,3.13.2-64,python.exe,,,,,,,
,,,,,,,,3.13-64,python.exe,,,,,,,
,,,,,,,,3-64,python.exe,,,,,,,
,,,,,,,,3.13.2-64,pythonw.exe,1,,,,,,
,,,,,,,,3.13-64,pythonw.exe,1,,,,,,
,,,,,,,,3-64,pythonw.exe,1,,,,,,
,,,,,,,,,,,python3.13.exe,python.exe,,,,
,,,,,,,,,,,python3.exe,python.exe,,,,
,,,,,,,,,,,pythonw3.13.exe,pythonw.exe,1,,,
,,,,,,,,,,,pythonw3.exe,pythonw.exe,1,,,

Proposed:

id,display-name,sort-version,company,tag,default,__any-platform,prefix,run-for.tag,run-for.target,run-for.windowed,alias.name,alias.target,alias.windowed,url,source,hash
pythoncore-3.13-64,Python 3.13.2,3.13.2,PythonCore,3.13-64,,,C:\Users\Adam\AppData\Local\Python\pythoncore-3.13-64,,,,,,,https://api.nuget.org/v3-flatcontainer/python/3.13.2/python.3.13.2.nupkg,file:///C:/Program Files/WindowsApps/PythonSoftwareFoundation.PythonManager_0.1.0.172_x64__7qnp2ymwnadz2/./bundled/index.json,
pythoncore-3.13-64,Python 3.13.2,3.13.2,PythonCore,3.13-64,,,C:\Users\Adam\AppData\Local\Python\pythoncore-3.13-64,3.13.2-64,python.exe,,,,,https://api.nuget.org/v3-flatcontainer/python/3.13.2/python.3.13.2.nupkg,file:///C:/Program Files/WindowsApps/PythonSoftwareFoundation.PythonManager_0.1.0.172_x64__7qnp2ymwnadz2/./bundled/index.json,
pythoncore-3.13-64,Python 3.13.2,3.13.2,PythonCore,3.13-64,,,C:\Users\Adam\AppData\Local\Python\pythoncore-3.13-64,3.13-64,python.exe,,,,,https://api.nuget.org/v3-flatcontainer/python/3.13.2/python.3.13.2.nupkg,file:///C:/Program Files/WindowsApps/PythonSoftwareFoundation.PythonManager_0.1.0.172_x64__7qnp2ymwnadz2/./bundled/index.json,
pythoncore-3.13-64,Python 3.13.2,3.13.2,PythonCore,3.13-64,,,C:\Users\Adam\AppData\Local\Python\pythoncore-3.13-64,3-64,python.exe,,,,,https://api.nuget.org/v3-flatcontainer/python/3.13.2/python.3.13.2.nupkg,file:///C:/Program Files/WindowsApps/PythonSoftwareFoundation.PythonManager_0.1.0.172_x64__7qnp2ymwnadz2/./bundled/index.json,
pythoncore-3.13-64,Python 3.13.2,3.13.2,PythonCore,3.13-64,,,C:\Users\Adam\AppData\Local\Python\pythoncore-3.13-64,3.13.2-64,pythonw.exe,1,,,,https://api.nuget.org/v3-flatcontainer/python/3.13.2/python.3.13.2.nupkg,file:///C:/Program Files/WindowsApps/PythonSoftwareFoundation.PythonManager_0.1.0.172_x64__7qnp2ymwnadz2/./bundled/index.json,
pythoncore-3.13-64,Python 3.13.2,3.13.2,PythonCore,3.13-64,,,C:\Users\Adam\AppData\Local\Python\pythoncore-3.13-64,3.13-64,pythonw.exe,1,,,,https://api.nuget.org/v3-flatcontainer/python/3.13.2/python.3.13.2.nupkg,file:///C:/Program Files/WindowsApps/PythonSoftwareFoundation.PythonManager_0.1.0.172_x64__7qnp2ymwnadz2/./bundled/index.json,
pythoncore-3.13-64,Python 3.13.2,3.13.2,PythonCore,3.13-64,,,C:\Users\Adam\AppData\Local\Python\pythoncore-3.13-64,3-64,pythonw.exe,1,,,,https://api.nuget.org/v3-flatcontainer/python/3.13.2/python.3.13.2.nupkg,file:///C:/Program Files/WindowsApps/PythonSoftwareFoundation.PythonManager_0.1.0.172_x64__7qnp2ymwnadz2/./bundled/index.json,
pythoncore-3.13-64,Python 3.13.2,3.13.2,PythonCore,3.13-64,,,C:\Users\Adam\AppData\Local\Python\pythoncore-3.13-64,,,,python3.13.exe,python.exe,,https://api.nuget.org/v3-flatcontainer/python/3.13.2/python.3.13.2.nupkg,file:///C:/Program Files/WindowsApps/PythonSoftwareFoundation.PythonManager_0.1.0.172_x64__7qnp2ymwnadz2/./bundled/index.json,
pythoncore-3.13-64,Python 3.13.2,3.13.2,PythonCore,3.13-64,,,C:\Users\Adam\AppData\Local\Python\pythoncore-3.13-64,,,,python3.exe,python.exe,,https://api.nuget.org/v3-flatcontainer/python/3.13.2/python.3.13.2.nupkg,file:///C:/Program Files/WindowsApps/PythonSoftwareFoundation.PythonManager_0.1.0.172_x64__7qnp2ymwnadz2/./bundled/index.json,
pythoncore-3.13-64,Python 3.13.2,3.13.2,PythonCore,3.13-64,,,C:\Users\Adam\AppData\Local\Python\pythoncore-3.13-64,,,,pythonw3.13.exe,pythonw.exe,1,https://api.nuget.org/v3-flatcontainer/python/3.13.2/python.3.13.2.nupkg,file:///C:/Program Files/WindowsApps/PythonSoftwareFoundation.PythonManager_0.1.0.172_x64__7qnp2ymwnadz2/./bundled/index.json,
pythoncore-3.13-64,Python 3.13.2,3.13.2,PythonCore,3.13-64,,,C:\Users\Adam\AppData\Local\Python\pythoncore-3.13-64,,,,pythonw3.exe,pythonw.exe,1,https://api.nuget.org/v3-flatcontainer/python/3.13.2/python.3.13.2.nupkg,file:///C:/Program Files/WindowsApps/PythonSoftwareFoundation.PythonManager_0.1.0.172_x64__7qnp2ymwnadz2/./bundled/index.json,

A

@zooba
Copy link
Member

zooba commented May 1, 2025

Want to add some tests for this while you're here? I'd suggest:

  • modify format_csv to take an optional output stream (default to sys.stdout)
  • call it directly with made up dicts from test_list.py and check a few output cases

Ideally just enough testing to get 100% of the diff covered, but at least enough for the overall coverage to not go backwards. I want to slowly increase coverage over time.

@zooba
Copy link
Member

zooba commented May 1, 2025

But yeah, I agree, the dense format is likely more useful. Terribly verbose, but there's really no way around that (apart from using the JSON formatting).

@zooba zooba merged commit e3b6475 into main May 16, 2025
5 checks passed
@zooba zooba deleted the improve-csv branch May 16, 2025 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants