Skip to content
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

The __str__ method of ProcessResult uses too much space when printing parsed JSON. #42

Closed
s0undt3ch opened this issue Feb 23, 2024 · 0 comments
Assignees

Comments

@s0undt3ch
Copy link
Contributor

When printing an instance of ProcessResult, if any JSON was parsed, it uses pprint.pformat to pretty print it, but that just uses too much space.

>>> d = {'author': 'The Python Packaging Authority',
...  'author_email': 'pypa-dev@googlegroups.com',
...  'bugtrack_url': None,
...  'classifiers': ['Development Status :: 3 - Alpha',
...                  'Intended Audience :: Developers',
...                  'License :: OSI Approved :: MIT License',
...                  'Programming Language :: Python :: 2',
...                  'Programming Language :: Python :: 2.6',
...                  'Programming Language :: Python :: 2.7',
...                  'Programming Language :: Python :: 3',
...                  'Programming Language :: Python :: 3.2',
...                  'Programming Language :: Python :: 3.3',
...                  'Programming Language :: Python :: 3.4',
...                  'Topic :: Software Development :: Build Tools'],
...  'description': 'A sample Python project\n'
...                 '=======================\n'
...                 '\n'
...                 'This is the description file for the project.\n'
...                 '\n'
...                 'The file should use UTF-8 encoding and be written using '
...                 'ReStructured Text. It\n'
...                 'will be used to generate the project webpage on PyPI, and '
...                 'should be written for\n'
...                 'that purpose.\n'
...                 '\n'
...                 'Typical contents for this file would include an overview of '
...                 'the project, basic\n'
...                 'usage examples, etc. Generally, including the project '
...                 'changelog in here is not\n'
...                 'a good idea, although a simple "What\'s New" section for the '
...                 'most recent version\n'
...                 'may be appropriate.',
...  'description_content_type': None,
...  'docs_url': None,
...  'download_url': 'UNKNOWN',
...  'downloads': {'last_day': -1, 'last_month': -1, 'last_week': -1},
...  'home_page': 'https://github.com/pypa/sampleproject',
...  'keywords': 'sample setuptools development',
...  'license': 'MIT',
...  'maintainer': None,
...  'maintainer_email': None,
...  'name': 'sampleproject',
...  'package_url': 'https://pypi.org/project/sampleproject/',
...  'platform': 'UNKNOWN',
...  'project_url': 'https://pypi.org/project/sampleproject/',
...  'project_urls': {'Download': 'UNKNOWN',
...                   'Homepage': 'https://github.com/pypa/sampleproject'},
...  'release_url': 'https://pypi.org/project/sampleproject/1.2.0/',
...  'requires_dist': None,
...  'requires_python': None,
...  'summary': 'A sample Python project',
...  'version': '1.2.0'}
>>> pprint.pprint(d)
{'author': 'The Python Packaging Authority',
 'author_email': 'pypa-dev@googlegroups.com',
 'bugtrack_url': None,
 'classifiers': ['Development Status :: 3 - Alpha',
                 'Intended Audience :: Developers',
                 'License :: OSI Approved :: MIT License',
                 'Programming Language :: Python :: 2',
                 'Programming Language :: Python :: 2.6',
                 'Programming Language :: Python :: 2.7',
                 'Programming Language :: Python :: 3',
                 'Programming Language :: Python :: 3.2',
                 'Programming Language :: Python :: 3.3',
                 'Programming Language :: Python :: 3.4',
                 'Topic :: Software Development :: Build Tools'],
 'description': 'A sample Python project\n'
                '=======================\n'
                '\n'
                'This is the description file for the project.\n'
                '\n'
                'The file should use UTF-8 encoding and be written using '
                'ReStructured Text. It\n'
                'will be used to generate the project webpage on PyPI, and '
                'should be written for\n'
                'that purpose.\n'
                '\n'
                'Typical contents for this file would include an overview of '
                'the project, basic\n'
                'usage examples, etc. Generally, including the project '
                'changelog in here is not\n'
                'a good idea, although a simple "What\'s New" section for the '
                'most recent version\n'
                'may be appropriate.',
 'description_content_type': None,
 'docs_url': None,
 'download_url': 'UNKNOWN',
 'downloads': {'last_day': -1, 'last_month': -1, 'last_week': -1},
 'home_page': 'https://github.com/pypa/sampleproject',
 'keywords': 'sample setuptools development',
 'license': 'MIT',
 'maintainer': None,
 'maintainer_email': None,
 'name': 'sampleproject',
 'package_url': 'https://pypi.org/project/sampleproject/',
 'platform': 'UNKNOWN',
 'project_url': 'https://pypi.org/project/sampleproject/',
 'project_urls': {'Download': 'UNKNOWN',
                  'Homepage': 'https://github.com/pypa/sampleproject'},
 'release_url': 'https://pypi.org/project/sampleproject/1.2.0/',
 'requires_dist': None,
 'requires_python': None,
 'summary': 'A sample Python project',
 'version': '1.2.0'}
>>> print(json.dumps(d, indent=2))
{
  "author": "The Python Packaging Authority",
  "author_email": "pypa-dev@googlegroups.com",
  "bugtrack_url": null,
  "classifiers": [
    "Development Status :: 3 - Alpha",
    "Intended Audience :: Developers",
    "License :: OSI Approved :: MIT License",
    "Programming Language :: Python :: 2",
    "Programming Language :: Python :: 2.6",
    "Programming Language :: Python :: 2.7",
    "Programming Language :: Python :: 3",
    "Programming Language :: Python :: 3.2",
    "Programming Language :: Python :: 3.3",
    "Programming Language :: Python :: 3.4",
    "Topic :: Software Development :: Build Tools"
  ],
  "description": "A sample Python project\n=======================\n\nThis is the description file for the project.\n\nThe file should use UTF-8 encoding and be written using ReStructured Text. It\nwill be used to
 generate the project webpage on PyPI, and should be written for\nthat purpose.\n\nTypical contents for this file would include an overview of the project, basic\nusage examples, etc. Generally, including the proj
ect changelog in here is not\na good idea, although a simple \"What's New\" section for the most recent version\nmay be appropriate.",
  "description_content_type": null,
  "docs_url": null,
  "download_url": "UNKNOWN",
  "downloads": {
    "last_day": -1,
    "last_month": -1,
    "last_week": -1
  },
  "home_page": "https://github.com/pypa/sampleproject",
  "keywords": "sample setuptools development",
  "license": "MIT",
  "maintainer": null,
  "maintainer_email": null,
  "name": "sampleproject",
  "package_url": "https://pypi.org/project/sampleproject/",
  "platform": "UNKNOWN",
  "project_url": "https://pypi.org/project/sampleproject/",
  "project_urls": {
    "Download": "UNKNOWN",
    "Homepage": "https://github.com/pypa/sampleproject"
  },
  "release_url": "https://pypi.org/project/sampleproject/1.2.0/",
  "requires_dist": null,
  "requires_python": null,
  "summary": "A sample Python project",
  "version": "1.2.0"
}
>>>

And with salt state returns, it becomes even worse.

s0undt3ch added a commit to s0undt3ch/pytest-shell-utilities that referenced this issue Feb 23, 2024
s0undt3ch added a commit to s0undt3ch/pytest-shell-utilities that referenced this issue Feb 23, 2024
@s0undt3ch s0undt3ch self-assigned this Feb 23, 2024
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

No branches or pull requests

1 participant