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

✨ [yaml2json] Add script #16

Merged
merged 6 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
mbox2maildir
stardate
python-stdlib
yaml2json
contributing
Code of Conduct <codeofconduct>
License <license>
Expand Down
4 changes: 4 additions & 0 deletions docs/yaml2json.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
yaml2json
=========

TBD
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def mypy(session: Session) -> None:
"""Type-check using mypy."""
args = session.posargs or ["src", "tests", "docs/conf.py"]
session.install(".")
session.install("mypy", "pytest")
session.install("mypy", "pytest", "types-PyYAML")
session.run("mypy", *args)
if not session.posargs:
session.run("mypy", f"--python-executable={sys.executable}", "noxfile.py")
Expand Down
16 changes: 14 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ rich = ">=10.15.2"
matplotlib = ">=3.5.0"
"github3.py" = ">=3.0.0"
Pygments = ">=2.10.0"
PyYAML = ">=6.0"

[tool.poetry.dev-dependencies]
pytest = ">=6.2.5"
Expand All @@ -50,13 +51,15 @@ Pygments = ">=2.10.0"
pyupgrade = ">=2.29.1"
furo = ">=2021.11.12"
sphinx-argparse = ">=0.3.1"
types-PyYAML = ">=6.0.1"

[tool.poetry.scripts]
stardate = "cjolowicz_scripts.stardate:main"
dependabot-rebase-all = "cjolowicz_scripts.dependabot_rebase_all:main"
mbox2maildir = "cjolowicz_scripts.mbox2maildir:main"
python-stdlib = "cjolowicz_scripts.python_stdlib:main"
compare-tools = "cjolowicz_scripts.compare_tools:main"
yaml2json = "cjolowicz_scripts.yaml2json:main"

[tool.coverage.paths]
source = ["src", "*/site-packages"]
Expand Down
18 changes: 18 additions & 0 deletions src/cjolowicz_scripts/yaml2json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Convert YAML to JSON."""
import json
import sys

import yaml


def main() -> None:
"""Convert YAML to JSON."""
data = yaml.safe_load(sys.stdin)

json.dump(data, sys.stdout, sort_keys=True, indent=2)

print()


if __name__ == "__main__":
main()