X-Git-Url: https://mudpy.org/gitweb?a=blobdiff_plain;f=lib%2Fmudpy%2Fdata.py;h=de7641685189541ba0764f16c9ae4335b597b822;hb=86ca67c3421f3ea64f60f67f4fd43acb662b2cf7;hp=243a28bc93f914c864d311750f36a70ee12fd07f;hpb=8e20f5d1b5949453bd71d332198b5266184bc2a4;p=mudpy.git diff --git a/lib/mudpy/data.py b/lib/mudpy/data.py index 243a28b..de76416 100644 --- a/lib/mudpy/data.py +++ b/lib/mudpy/data.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Data interface functions for the mudpy engine.""" -# Copyright (c) 2004-2011 Jeremy Stanley . Permission +# Copyright (c) 2004-2013 Jeremy Stanley . Permission # to use, copy, modify, and distribute this software is granted under # terms provided in the LICENSE file distributed with this software. @@ -17,11 +17,15 @@ class DataFile: def load(self): """Read a file and create elements accordingly.""" - import ConfigParser - import misc + import mudpy.misc import os import os.path - self.data = ConfigParser.RawConfigParser() + # TODO: remove this check after the switch to py3k + try: + import configparser + except ImportError: + import ConfigParser as configparser + self.data = configparser.RawConfigParser() self.modified = False if os.access(self.filename, os.R_OK): self.data.read(self.filename) @@ -83,7 +87,7 @@ class DataFile: self.universe.private_files.append(item) for section in self.data.sections(): if section != "__control__": - misc.Element(section, self.universe, self.filename) + mudpy.misc.Element(section, self.universe, self.filename) for include_file in includes: if not os.path.isabs(include_file): include_file = find_file( @@ -151,10 +155,10 @@ class DataFile: # if it's marked private, chmod it appropriately if self.filename in self.universe.private_files and oct( stat.S_IMODE(os.stat(self.filename)[stat.ST_MODE]) - ) != 0600: - os.chmod(self.filename, 0600) + ) != 0o0600: + os.chmod(self.filename, 0o0600) - # write it back sorted, instead of using ConfigParser + # write it back sorted, instead of using configparser sections = self.data.sections() sections.sort() for section in sections: @@ -227,8 +231,9 @@ def find_file( # if there's only one file loaded, try to work around a chicken