X-Git-Url: https://mudpy.org/gitweb?p=mudpy.git;a=blobdiff_plain;f=lib%2Fmudpy%2Fdata.py;h=f254dc6dc67a057871f8f79870bd566dbea8a4f5;hp=ca47f835b210d0119503e929a817a16bec3567e8;hb=b30249dada13540bf31fcd8b442efa3802717626;hpb=b6b6478cf56b8d0defd158868c91f88c150313ed diff --git a/lib/mudpy/data.py b/lib/mudpy/data.py index ca47f83..f254dc6 100644 --- a/lib/mudpy/data.py +++ b/lib/mudpy/data.py @@ -4,7 +4,6 @@ # 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 @@ -30,11 +29,12 @@ class DataFile: self.data = yaml.load(open(self.filename)) except FileNotFoundError: # it's normal if the file is one which doesn't exist yet + log_entry = ("File %s is unavailable." % self.filename, 6) try: - mudpy.misc.log("Couldn't read %s file." % self.filename, 6) + mudpy.misc.log(*log_entry) except NameError: # happens when we're not far enough along in the init process - pass + self.universe.setup_loglines.append(log_entry) if not hasattr(self.universe, "files"): self.universe.files = {} self.universe.files[self.filename] = self @@ -144,7 +144,7 @@ class DataFile: os.rename(self.filename, self.filename + ".0") # our data file - file_descriptor = codecs.open(self.filename, "w", "utf-8") + file_descriptor = open(self.filename, "w") # if it's marked private, chmod it appropriately if self.filename in self.universe.private_files and oct( @@ -152,9 +152,9 @@ class DataFile: ) != 0o0600: os.chmod(self.filename, 0o0600) - # write, flush and close the file - file_descriptor.write(yaml.dump(self.data)) - file_descriptor.flush() + # write and close the file + yaml.dump(self.data, allow_unicode=True, default_flow_style=False, + stream=file_descriptor) file_descriptor.close() # unset the modified flag