Created
December 9, 2021 15:25
-
-
Save aviflax/ce3042a693b5e5c32c8ca8dd4878a978 to your computer and use it in GitHub Desktop.
Structurizr scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import fileinput | |
def cleanup(line: str) -> str: | |
return line.replace(" ", " ").replace('xml:space="preserve"', "") | |
def __main__(): | |
# inplace=True causes standard output to be directed to the input file | |
for line in fileinput.input(inplace=True, backup=".bak"): | |
# since the line already ends with a newline char, we use end to avoid adding another | |
print(cleanup(line), end="") | |
if __name__ == "__main__": | |
__main__() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bb | |
(require '[clojure.data.xml :as xml] | |
'[clojure.java.io :as io]) | |
(defn main [file-paths] | |
(doseq [fp file-paths] | |
(->> (io/reader fp) | |
(xml/parse) | |
(xml/indent-str) | |
(spit fp)))) | |
(when (= *file* (System/getProperty "babashka.file")) | |
(main *command-line-args*)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment