From e34ba9c2fe759c547202a64b2dc40112d8e1d8c4 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Sat, 23 Apr 2011 16:26:27 +0000 Subject: add missing ']'s to json strings (#2796) --- diff --git a/TurtleArt/tautils.py b/TurtleArt/tautils.py index c027537..39ac2c2 100644 --- a/TurtleArt/tautils.py +++ b/TurtleArt/tautils.py @@ -121,15 +121,22 @@ def json_load(text): if OLD_SUGAR_SYSTEM is True: _listdata = json.read(text) else: - # strip out leading and trailing whitespace, nulls, and newlines + # Strip out leading and trailing whitespace, nulls, and newlines clean_text = text.lstrip() clean_text = clean_text.replace('\12', '') clean_text = clean_text.replace('\00', '') - _io = StringIO(clean_text.rstrip()) + clean_text = clean_text.rstrip() + # Look for missing ']'s + left_count = clean_text.count('[') + right_count = clean_text.count(']') + while left_count > right_count: + clean_text += ']' + right_count = clean_text.count(']') + _io = StringIO(clean_text) try: _listdata = jload(_io) except ValueError: - # assume that text is ascii list + # Assume that text is ascii list _listdata = text.split() for i, value in enumerate(_listdata): _listdata[i] = convert(value, float) -- cgit v0.9.1