Created
April 8, 2016 11:34
-
-
Save rhizoome/8f4c5cf6d7c2f697f7f35603a96a4252 to your computer and use it in GitHub Desktop.
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 python | |
import tempfile | |
import sys | |
import os | |
import subprocess | |
proc = None | |
try: | |
tmp = tempfile.NamedTemporaryFile(delete=False) | |
tmp.write(sys.stdin.read().encode("UTF-8")) | |
tmp.close() | |
proc = subprocess.Popen([ | |
"pyformat", | |
"-i", | |
tmp.name | |
]) | |
proc.wait() | |
with open(tmp.name, "r") as file_: | |
sys.stdout.write(file_.read()) | |
os.unlink(tmp.name) | |
finally: | |
proc.terminate() | |
sys.exit(proc.returncode) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment