Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(3)  |  Call(1)  |  Derive(0)  |  Import(2)
Helper function. Returns a file open for writing into the file named
'fname'.  If fname already exists, opens 'fname.1' or 'fname.2' or
'fname.3' or so on.

        def openUnique(fname, mode='w', perms=0600):
    """Helper function. Returns a file open for writing into the file named
       'fname'.  If fname already exists, opens 'fname.1' or 'fname.2' or
       'fname.3' or so on."""
    if 'b' in mode:
        bin = O_BINARY
    else:
        bin = 0
    base, rest = os.path.split(fname)
    idx = 0
    while 1:
        try:
            fd = os.open(fname, os.O_WRONLY|os.O_CREAT|os.O_EXCL|bin, perms)
            return os.fdopen(fd, mode), fname
        except OSError, e:
            if e.errno != errno.EEXIST:
                raise
        idx += 1
        fname = os.path.join(base, "%s.%s"%(rest,idx))

    raise MixFatalError("unreachable code")
        


src/m/i/mixminion-HEAD/lib/mixminion/ClientDirectory.py   mixminion(Download)
import mixminion.ServerInfo
 
from mixminion.Common import LOG, MixError, MixFatalError, UIError, \
     ceilDiv, createPrivateDir, formatDate, formatFnameTime, openUnique, \
     previousMidnight, readPickled, readPossiblyGzippedFile, \
            raise UIError("Server descriptor is already superseded")
 
        f, fname = openUnique(os.path.join(self.directory,nameBase))
        f.write(contents)
        f.close()

src/m/i/mixminion-HEAD/lib/mixminion/directory/ServerList.py   mixminion(Download)
from mixminion.Crypto import pk_decode_public_key, pk_encode_public_key, \
     pk_same_public_key
from mixminion.Common import IntervalSet, LOG, MixError, MixFatalError, \
     UIError, createPrivateDir, formatBase64, formatDate, formatFnameTime, \
     formatTime, iterFileLines, Lockfile, openUnique, previousMidnight, readFile,\