Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add JSON as a format option for
targets
command in `build_examples.…
…py` (#25810) * Add JSON as a format option for `targets` command The `targets` command outputs the targets that are available for the `build` and `gen` commands in a string format that is easy to read but hard to parse. This change adds a option for the `targets` command to output JSON so that the available targets can be more easily parsed. To do this, ToDict methods were added to BuildTarget and TargetPart classes. When the `--format json` option is used with the `targets` command `build_examples.py` calls the ToDict method of each BuildTarget object and outputs to stdout a list of Dicts in JSON, one for each BuildTarget. * Restyled by autopep8 * Restyled by isort * Simplfy code (loops) for creating Dicts and Lists Simplied the code that ceates dictionaries and lists from data contained within the BuildTarget and TargetPart objects. Also, corrected some comments, and put List and Dict types where appropriate. * Fixed BuildTarget ToDict method BuildTarget ToDict method was incorrectly converting the fixed_targets list to a dictionary, losing data. * Changed ToDict of BuildTarget to use a list of lists. Each time AppendFixedTargets method of BuildTarget is called, a list of TargetPart objects is appended to the fixed_targets list. This change perserves the developer's intent by keeping the list of lists structure intact rather than flatting it out into one list. --------- Co-authored-by: Restyled.io <[email protected]>
- Loading branch information