Skip to content

Instantly share code, notes, and snippets.

@rhizoome
Created April 8, 2016 11:34
Show Gist options
  • Save rhizoome/8f4c5cf6d7c2f697f7f35603a96a4252 to your computer and use it in GitHub Desktop.
Save rhizoome/8f4c5cf6d7c2f697f7f35603a96a4252 to your computer and use it in GitHub Desktop.
#!/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