source/tools/xfmt/__main__.py

26 lines
412 B
Python
Raw Normal View History

2021-04-08 06:37:51 +00:00
#!/usr/bin/env python3
"""
A quick and dirty XML formatter.
"""
from bs4 import BeautifulSoup
import click
@click.command()
@click.argument("filename")
def main(filename):
with open(filename) as f:
bs = BeautifulSoup(f, "xml")
with open(filename, "w") as of:
of.write(bs.prettify())
of.write("\n")
print(f"Formatted {filename}!")
if __name__ == "__main__":
main()