Break tools out into their own dirs
This commit is contained in:
parent
b56030804c
commit
3b9e4076a5
15 changed files with 59 additions and 66 deletions
tools/xfmt
9
tools/xfmt/BUILD
Normal file
9
tools/xfmt/BUILD
Normal 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
25
tools/xfmt/__main__.py
Normal 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()
|
Loading…
Add table
Add a link
Reference in a new issue