Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarion <marion.zepf@gmail.com>2013-08-11 21:59:42 (GMT)
committer Marion <marion.zepf@gmail.com>2013-08-11 21:59:42 (GMT)
commit52cef114510a08b3fc89a974ad6ee8bfb39e5dae (patch)
treeb7a77dc277505b52efb260d32187c1045f3ba0ae
parent8913f29678d54cc3cbf6cbcb612712c805dd9f35 (diff)
return None as the value of non-value blocks
-rw-r--r--TurtleArt/tablock.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/TurtleArt/tablock.py b/TurtleArt/tablock.py
index 4c0f207..36a2070 100644
--- a/TurtleArt/tablock.py
+++ b/TurtleArt/tablock.py
@@ -287,10 +287,13 @@ class Block:
return self.primitive is None and self.values
def get_value(self, add_type_prefix=True):
- """ Return the value stored in this value block
+ """ Return the value stored in this value block or None if this is
+ not a value block
add_type_prefix -- prepend a prefix to indicate the type of the
'raw' value """
- # TODO what error to raise if this is not a value block?
+ if not self.is_value_block():
+ return None
+
result = ''
if self.name == 'number':
try:
@@ -310,10 +313,7 @@ class Block:
elif self.name in PREFIX_DICTIONARY:
if add_type_prefix:
result = PREFIX_DICTIONARY[self.name]
- if self.values[0] is not None:
- result += str(self.values[0])
- else:
- result += 'None'
+ result += str(self.values[0])
elif self.name in media_blocks_dictionary:
if add_type_prefix:
result = '#smedia_'