Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt/tautils.py
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2013-01-17 17:23:50 (GMT)
committer Walter Bender <walter.bender@gmail.com>2013-01-17 17:23:50 (GMT)
commit383de1d3c95423b53eff8d972c2dd7706a37d9dd (patch)
treedfe8b20e2f7a6913bf6e3332ec5d879bf1536e8e /TurtleArt/tautils.py
parent1722c6bc5aa95337c4a56f1bd2fbb43318bbeca3 (diff)
using constants for suffix and mimetype
Diffstat (limited to 'TurtleArt/tautils.py')
-rw-r--r--TurtleArt/tautils.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/TurtleArt/tautils.py b/TurtleArt/tautils.py
index 7d3a351..5f1635b 100644
--- a/TurtleArt/tautils.py
+++ b/TurtleArt/tautils.py
@@ -1,5 +1,5 @@
#copyright (c) 2007-8, Playful Invention Company.
-#Copyright (c) 2008-12, Walter Bender
+#Copyright (c) 2008-13, Walter Bender
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
@@ -44,7 +44,7 @@ except (ImportError, AttributeError):
from StringIO import StringIO
from taconstants import (HIT_HIDE, HIT_SHOW, XO1, XO15, XO175, XO30, XO4,
- UNKNOWN)
+ UNKNOWN, MAGICNUMBER)
import logging
_logger = logging.getLogger('turtleart-activity')
@@ -140,8 +140,12 @@ def json_load(text):
if OLD_SUGAR_SYSTEM is True:
listdata = json.read(text)
else:
- # Strip out leading and trailing whitespace, nulls, and newlines
- clean_text = text.lstrip()
+ # Remove MAGIC NUMBER, if present, and leading whitespace
+ if text[0:2] == MAGICNUMBER:
+ clean_text = text[2:].lstrip()
+ else:
+ clean_text = text.lstrip()
+ # Strip out trailing whitespace, nulls, and newlines
clean_text = clean_text.replace('\12', '')
clean_text = clean_text.replace('\00', '')
clean_text = clean_text.rstrip()