Skip to content

feat: argparse for validate.py; pretty JSON output in schema generator - #184

Open
SoundMatt wants to merge 1 commit into
COVESA:masterfrom
SoundMatt:feat/ifex-101-argparse-pretty-schema
Open

feat: argparse for validate.py; pretty JSON output in schema generator#184
SoundMatt wants to merge 1 commit into
COVESA:masterfrom
SoundMatt:feat/ifex-101-argparse-pretty-schema

Conversation

@SoundMatt

Copy link
Copy Markdown
Contributor

Closes #101

Changes

  • validate.py: Replace bare sys.argv indexing with argparse. Running without arguments now prints a proper usage message instead of throwing IndexError. The --quiet flag is preserved as a named argument.

  • ifex_to_json_schema.py: Capture all print() output via io.StringIO / redirect_stdout, then parse and re-emit with json.dumps(indent=2). The schema is now pretty-printed without needing an external pipe step.

  • pretty_print_json.py: Deleted. Its sole purpose was piping the schema generator output through json.dumps; that is now done internally.

Test

# Usage message instead of IndexError
python -m ifex.output_filters.schema.validate

# Pretty-printed schema directly
python -m ifex.output_filters.schema.ifex_to_json_schema | head -20

COVESA#101)

- validate.py: replace bare sys.argv indexing with argparse, giving
  a proper usage message when arguments are missing
- ifex_to_json_schema.py: capture print output via StringIO and
  re-emit it through json.dumps(indent=2), so the schema is
  pretty-printed without needing an external pipe
- pretty_print_json.py: deleted; its function is now built into
  ifex_to_json_schema.py

Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.com>
@gunnar-mb

Copy link
Copy Markdown
Collaborator

Good fix, but CI/CD must be updated since these files use pretty_print_json.py‎:

  • .github/workflows/create-new-release.yml
  • .github/workflows/buildcheck.yml

Also since JSON publication is part of release flow, test first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve user friendliness of json schema generator and validator

2 participants