Esempio n. 1
0
def _open_file(path):
    if path == "-":
        return util.StdIOContextManager(sys.stdout)
    util.ensure_dir(os.path.dirname(path))
    try:
        return open(path, "w")
    except (OSError, IOError) as e:
        cli.error("error opening %s: %s" % (path, e))
Esempio n. 2
0
def _open_file(path):
    if path == "-":
        return util.StdIOContextManager(sys.stdout)
    return open(path, "w")