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

All Samples(8)  |  Call(5)  |  Derive(0)  |  Import(3)
Read the contents of the file <fname>.  If <fname> ends with ".gz",
treat it as a gzipped file.

        def readPossiblyGzippedFile(fname, mode='r'):
    """Read the contents of the file .  If  ends with ".gz",
       treat it as a gzipped file."""
    f = None
    try:
        if fname.endswith(".gz"):
            f = gzip.GzipFile(fname, 'rb')
        else:
            f = open(fname, 'r')
        return f.read()
    finally:
        if f is not None:
            f.close()
        


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, \
           in.  Does *not* remove any descriptors superseded by sourceFName.
        """
        contents = readPossiblyGzippedFile(sourceFname)
        try:
            s = mixminion.ServerInfo.ServerInfo(string=contents,assumeValid=0)

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,\

src/m/i/mixminion-HEAD/lib/mixminion/Config.py   mixminion(Download)
 
        if filename and not string:
            string = mixminion.Common.readPossiblyGzippedFile(filename)
        self.fname = filename
 

src/m/i/mixminion-HEAD/lib/mixminion/ServerInfo.py   mixminion(Download)
import mixminion.Packet
 
from mixminion.Common import IntervalSet, LOG, MixError, createPrivateDir, \
     formatBase64, formatDate, formatTime, readPossiblyGzippedFile
from mixminion.Config import ConfigError
        else:
            try:
                contents = readPossiblyGzippedFile(fname)
            except (IOError, zlib.error), e:
                raise ConfigError("Couldn't decompress %s: %s"%(fname,e))
        else:
            try:
                contents = readPossiblyGzippedFile(fname)
            except (IOError, zlib.error), e:
                raise ConfigError("Couldn't decompress %s: %s"%(fname,e))
def parseDirectory(fname, validatedDigests=None):
    """DOCDOC"""
    try:
        s = readPossiblyGzippedFile(fname)
    except (IOError, zlib.error), e: