X-Git-Url: https://mudpy.org/gitweb?p=mudpy.git;a=blobdiff_plain;f=lib%2Fmudpy%2Fdata.py;h=ad171d8a8c6c27537cdb38936759eb24b187e108;hp=cdb114ff6049e5cda3ae33db98546895faacebd5;hb=afe9aa24f4f7cbc58b43faf18a7f0f35bf71eb7c;hpb=f5e94fa07660dbcfd3e5531c40bc3064679b2f95 diff --git a/lib/mudpy/data.py b/lib/mudpy/data.py index cdb114f..ad171d8 100644 --- a/lib/mudpy/data.py +++ b/lib/mudpy/data.py @@ -1,10 +1,19 @@ # -*- coding: utf-8 -*- """Data interface functions for the mudpy engine.""" -# Copyright (c) 2004-2012 Jeremy Stanley . Permission +# Copyright (c) 2004-2014 Jeremy Stanley . Permission # to use, copy, modify, and distribute this software is granted under # terms provided in the LICENSE file distributed with this software. +import codecs +import configparser +import os +import re +import stat +import sys + +import mudpy + class DataFile: @@ -17,11 +26,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 +102,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 ( @@ -151,10 +151,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: @@ -193,9 +193,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: @@ -227,8 +224,9 @@ def find_file( # if there's only one file loaded, try to work around a chicken