예제 #1
0
def test_tmppath():
    path = temps.tmppath()
    assert not os.path.exists(path)
    try:
        os.mkdir(path)
    finally:
        if os.path.isdir(path):
            os.rmdir(path)
예제 #2
0
파일: test_temps.py 프로젝트: yaccz/temps
def test_tmppath():
    path = temps.tmppath()
    assert not os.path.exists(path)
    try:
        os.mkdir(path)
    finally:
        if os.path.isdir(path):
            os.rmdir(path)
예제 #3
0
파일: filemsg.py 프로젝트: gorysko/roundup
def dump(msg, filename=None):
    '''
    Write a message to a file.  If filename is None, a unique hexadecimal
    temporary filename will be used.  Either way, the filename is returned, so
    it can be communicated to whoever will read the file.
    '''
    if filename is None:
        filename = temps.tmppath()

    with open(filename, 'wb') as fh:
        pickle.dump(msg, fh, pickle.HIGHEST_PROTOCOL)

    return filename