Пример #1
0
def read_proc(path):
    path = proc_path(path)
    try:
        fp = open_text(path)
        try:
            for line in fp:
                yield line.rstrip()
        finally:
            # don't use context manager to support StringIO on Python 2
            # for unit tests
            fp.close()
    except (OSError, IOError):
        return
Пример #2
0
def read_proc(path):
    path = proc_path(path)
    try:
        fp = open_text(path)
        try:
            for line in fp:
                yield line.rstrip()
        finally:
            # don't use context manager to support StringIO on Python 2
            # for unit tests
            fp.close()
    except (OSError, IOError):
        return
Пример #3
0
def write_text(filename, content):
    with open_text(filename, write=True) as fp:
        fp.write(content)
        fp.flush()
Пример #4
0
def write_text(filename, content):
    with open_text(filename, write=True) as fp:
        fp.write(content)
        fp.flush()