Break tools out into their own dirs

This commit is contained in:
Reid 'arrdem' McKenzie 2021-08-29 22:13:59 -06:00
commit 3b9e4076a5
15 changed files with 59 additions and 66 deletions

9
tools/xfmt/BUILD Normal file
View file

@ -0,0 +1,9 @@
py_binary(
name = "xfmt",
main = "__main__.py",
deps = [
py_requirement("beautifulsoup4"),
py_requirement("click"),
py_requirement("lxml"),
]
)

25
tools/xfmt/__main__.py Normal file
View file

@ -0,0 +1,25 @@
#!/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()