X-Git-Url: https://mudpy.org/gitweb?p=mudpy.git;a=blobdiff_plain;f=lib%2Fmudpy%2Fdata.py;h=9ee09e15929cc5c3612f81e54ab4f6c0bfe6d214;hp=db27d55ab0e8beb1826e7c68b237295bfa5d8d86;hb=7549f8f2b17705dcd20e9ae827f2f4d067d8d9a6;hpb=2a2a4dd5265401038795a81815141e277998c33f diff --git a/lib/mudpy/data.py b/lib/mudpy/data.py index db27d55..9ee09e1 100644 --- a/lib/mudpy/data.py +++ b/lib/mudpy/data.py @@ -23,6 +23,7 @@ class DataFile: def __init__(self, filename, universe): self.filename = filename self.universe = universe + self.data = {} self.load() def load(self): @@ -270,14 +271,20 @@ class DataFile: # unset the modified flag self.modified = False - # TODO(fungi): this should support writing YAML def is_writeable(self): """Returns True if the __control__ read_only is False.""" - return not self.data.has_option( - "__control__", "read_only" - ) or not self.data.getboolean( - "__control__", "read_only" - ) + # TODO(fungi): remove this indirection after the YAML transition + if self._format == "yaml": + try: + return not self.data["__control__"].get("read_only", False) + except KeyError: + return True + else: + return not self.data.has_option( + "__control__", "read_only" + ) or not self.data.getboolean( + "__control__", "read_only" + ) def find_file(