in usort/api.py [0:0]
def usort_stdin() -> bool:
"""
Read file contents from stdin, format it, and write the resulting file to stdout
In case of error during sorting, no output will be written to stdout, and the
exception will be written to stderr instead.
Returns True if formatting succeeded, otherwise False
"""
if sys.stdin.isatty():
print("Warning: stdin is a tty", file=sys.stderr)
try:
config = Config.find()
data = sys.stdin.read()
result = usort_string(data, config, Path("<stdin>"))
sys.stdout.write(result)
return True
except Exception as e:
sys.stderr.write(repr(e))
return False