1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-25 16:02:28 +01:00

Use RawConfigParser instead of ConfigParser

This commit is contained in:
Dan O'Reilly
2008-12-13 17:32:54 -05:00
parent 20d5fd285b
commit 742bf5f8ce

View File

@@ -24,15 +24,15 @@ reusable for other purposes as well.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from ConfigParser import ConfigParser
from ConfigParser import RawConfigParser
from wicd.misc import stringToNone
class ConfigManager(ConfigParser):
class ConfigManager(RawConfigParser):
""" A class that can be used to manage a given configuration file. """
def __init__(self, path):
ConfigParser.__init__(self)
RawConfigParser.__init__(self)
self.config_file = path
self.read(path)
@@ -58,7 +58,7 @@ class ConfigManager(ConfigParser):
if not self.has_section(section):
self.add_section(section)
ConfigParser.set(self, section, str(option), str(value))
RawConfigParser.set(self, section, str(option), str(value))
if save:
self.write()
@@ -78,7 +78,7 @@ class ConfigManager(ConfigParser):
self.add_section(section)
if self.has_option(section, option):
ret = ConfigParser.get(self, section, option)
ret = RawConfigParser.get(self, section, option)
if default:
print ''.join(['found ', option, ' in configuration ', ret])
else:
@@ -101,7 +101,7 @@ class ConfigManager(ConfigParser):
def write(self):
""" Writes the loaded config file to disk. """
configfile = open(self.config_file, 'w')
ConfigParser.write(self, configfile)
RawConfigParser.write(self, configfile)
configfile.close()
def remove_section(self,section):
@@ -112,7 +112,7 @@ class ConfigManager(ConfigParser):
"""
if self.has_section(section):
ConfigParser.remove_section(self, section)
RawConfigParser.remove_section(self, section)
def reload(self):
self.read(self.config_file)