X-Git-Url: https://mudpy.org/gitweb?a=blobdiff_plain;f=lib%2Fmudpy%2Fdata.py;h=7d030c23346c1dab30352ddd48836785e0d7c797;hb=2a1119763de7805f617d8b62b8f0822969f3d7df;hp=612b688e1ed789c7b6a8e0636f6a8064e9dda312;hpb=3bb52cb5100b52500ca7368b979d501bdb83fd32;p=mudpy.git diff --git a/lib/mudpy/data.py b/lib/mudpy/data.py index 612b688..7d030c2 100644 --- a/lib/mudpy/data.py +++ b/lib/mudpy/data.py @@ -5,6 +5,20 @@ # to use, copy, modify, and distribute this software is granted under # terms provided in the LICENSE file distributed with this software. +import codecs +import os +import re +import stat +import sys + +# TODO: remove this check after the switch to py3k +try: + import configparser +except ImportError: + import ConfigParser as configparser + +import mudpy + class DataFile: @@ -17,11 +31,7 @@ class DataFile: def load(self): """Read a file and create elements accordingly.""" - import ConfigParser - import mudpy.misc - import os - import os.path - self.data = ConfigParser.RawConfigParser() + self.data = configparser.RawConfigParser() self.modified = False if os.access(self.filename, os.R_OK): self.data.read(self.filename) @@ -97,11 +107,6 @@ class DataFile: def save(self): """Write the data, if necessary.""" - import codecs - import os - import os.path - import re - import stat # when modified, writeable and has content or the file exists if self.modified and self.is_writeable() and ( @@ -154,7 +159,7 @@ class DataFile: ) != 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: @@ -193,9 +198,6 @@ def find_file( universe=None ): """Return an absolute file path based on configuration.""" - import os - import os.path - import sys # make sure to get rid of any surrounding quotes first thing if file_name: