Write empty array and dictionary items on one line.

Makes for slightly tidier plist text.
This commit is contained in:
Bill Currie 2012-08-31 16:14:49 +09:00
parent 43abf8e3df
commit c08fd08025

View file

@ -217,6 +217,9 @@ class pldata:
self.data.append(item) self.data.append(item)
def write_item(self, item, level): def write_item(self, item, level):
if type(item) == dict: if type(item) == dict:
if not item:
self.data.append("{ }")
return
self.data.append("{\n") self.data.append("{\n")
for i in item.items(): for i in item.items():
self.data.append('\t' * (level + 1)) self.data.append('\t' * (level + 1))
@ -227,6 +230,9 @@ class pldata:
self.data.append('\t' * (level)) self.data.append('\t' * (level))
self.data.append("}") self.data.append("}")
elif type(item) in(list, tuple): elif type(item) in(list, tuple):
if not item:
self.data.append("( )")
return
self.data.append("(\n") self.data.append("(\n")
for n, i in enumerate(item): for n, i in enumerate(item):
self.data.append('\t' * (level + 1)) self.data.append('\t' * (level + 1))