[Gelistirici] [Fwd: [Uludag-commits] r22795 - trunk/mudur/bin]

Ozan Çağlayan ozan at pardus.org.tr
17 Mayıs 2009 Paz 14:56:47 EEST


loadConfig() gerçekten dosyanın olup olmadığına bakıyor mu?

def loadConfig(path):
    d = {}
    for line in file(path):
        if line != "" and not line.startswith("#") and "=" in line:
            key, value = line.split("=", 1)
            key = key.strip()
            value = value.strip()
            if value.startswith('"') or value.startswith("'"):
                value = value[1:-1]
            d[key] = value
    return d

ipython'dan:

In [5]: for line in file("/etc/conf.d/mudur_"):
   ...:     print line
   ...:
   ...:
---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)

/root/uludag/trunk/mudur/<ipython console> in <module>()

IOError: [Errno 2] No such file or directory: '/etc/conf.d/mudur_'


-------- Original Message --------
Subject: [Uludag-commits] r22795 - trunk/mudur/bin
Date: Sun, 17 May 2009 01:40:19 +0300 (EEST)
From: uludag-commits at pardus.org.tr
Reply-To: gelistirici at pardus.org.tr
To: uludag-commits at pardus.org.tr

Author: fatih
Date: Sun May 17 01:40:19 2009
New Revision: 22795

Modified:
   trunk/mudur/bin/mudur.py
Log:
This is better I think ;) loadConfig already checks the existance of file.





Gelistirici mesaj listesiyle ilgili daha fazla bilgi