def writeValue(self, value, forKey=None, forType=None): if hasattr(value, "plistValue"): value = value.plistValue() if value is not None: self.file.write(value) elif forKey == "color" and hasattr(value, "__iter__"): # We have to write color tuples on one line or Glyphs 2.4.x # misreads it. self.file.write(str(tuple(value))) elif isinstance(value, (list, glyphsLib.classes.Proxy)): if isinstance(value, glyphsLib.classes.UserDataProxy): self.writeUserData(value) else: self.writeArray(value) elif isinstance(value, (dict, OrderedDict, glyphsLib.classes.GSBase)): self.writeDict(value) elif type(value) == float: self.file.write(floatToString(value, 5)) elif type(value) == int: self.file.write(str(value)) elif type(value) == bool: if value: self.file.write("1") else: self.file.write("0") elif type(value) == datetime.datetime: self.file.write('"%s +0000"' % str(value)) else: value = str(value) if forKey != "unicode": value = escape_string(value) self.file.write(value)
def writeValue(self, value, forKey=None, forType=None): if isinstance(value, (list, glyphsLib.classes.Proxy)): if isinstance(value, glyphsLib.classes.UserDataProxy): self.writeUserData(value) else: self.writeArray(value) elif hasattr(value, "plistValue"): value = value.plistValue() if value is not None: self.file.write(value) elif isinstance(value, (dict, OrderedDict, glyphsLib.classes.GSBase)): self.writeDict(value) elif type(value) == float: self.file.write(floatToString(value, 5)) elif type(value) == int: self.file.write(unicode(value)) elif type(value) == bool: if value: self.file.write("1") else: self.file.write("0") elif type(value) == datetime.datetime: self.file.write("\"%s +0000\"" % str(value)) else: if forKey != "unicode": value = feature_syntax_encode(value) self.file.write(unicode(value))