Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2013-05-22 21:48:47 (GMT)
committer Walter Bender <walter@sugarlabs.org>2013-05-22 21:48:47 (GMT)
commit87b47c329bf60c336303f228e11ece571dbe91de (patch)
tree49ae3e0722afb420a8e237384c8f36ecf4fb6f04
parent51d0563b974f4daa7150410f66d1816c42780212 (diff)
pep8 and pyflakes cleanup
-rw-r--r--pysamples/brain.py20
-rw-r--r--pysamples/csound.py44
-rw-r--r--pysamples/forward_push.py2
-rw-r--r--pysamples/grecord.py39
-rw-r--r--pysamples/journal-stats.py10
-rw-r--r--pysamples/load_block.py10
-rw-r--r--pysamples/push_mouse_event.py4
-rw-r--r--pysamples/serial.py16
-rw-r--r--pysamples/svg_end_group.py3
-rw-r--r--pysamples/svg_start_group.py2
-rw-r--r--pysamples/ta-stats.py100
-rw-r--r--pysamples/uturn.py6
12 files changed, 129 insertions, 127 deletions
diff --git a/pysamples/brain.py b/pysamples/brain.py
index 456df37..33ee320 100644
--- a/pysamples/brain.py
+++ b/pysamples/brain.py
@@ -45,21 +45,18 @@ def myblock(tw, text):
import sys
sys.path.append(speakpath)
- import gobject
import aiml
import voice
-
BOTS = {
- _('Spanish'): { 'name': 'Sara',
- 'brain': os.path.join(speakpath, 'bot', 'sara.brn'),
- 'predicates': { 'nombre_bot': 'Sara',
- 'botmaster': 'La comunidad Azucar' } },
- _('English'): { 'name': 'Alice',
- 'brain': os.path.join(speakpath, 'bot', 'alice.brn'),
- 'predicates': { 'name': 'Alice',
- 'master': 'The Sugar Community' } } }
-
+ _('Spanish'): {'name': 'Sara',
+ 'brain': os.path.join(speakpath, 'bot', 'sara.brn'),
+ 'predicates': {'nombre_bot': 'Sara',
+ 'botmaster': 'La comunidad Azucar'}},
+ _('English'): {'name': 'Alice',
+ 'brain': os.path.join(speakpath, 'bot', 'alice.brn'),
+ 'predicates': {'name': 'Alice',
+ 'master': 'The Sugar Community'}}}
def get_mem_info(tag):
meminfo = file('/proc/meminfo').readlines()
@@ -107,7 +104,6 @@ Close other activities and try once more.'))
return kernel
- kernel = None
if not hasattr(tw, 'aiml_kernel'):
tw.aiml_kernel = brain_load(tw, get_default_voice())
response_text = brain_respond(tw.aiml_kernel, text)
diff --git a/pysamples/csound.py b/pysamples/csound.py
index f2bccfa..a935674 100644
--- a/pysamples/csound.py
+++ b/pysamples/csound.py
@@ -16,12 +16,12 @@ def myblock(tw, sound):
from TurtleArt.tautils import get_path
import os
- dirs = [os.path.join(os.environ['HOME'],
- 'Activities/TamTamMini.activity/common/Resources/Sounds/')]
+ dirs = [os.path.join(
+ os.environ['HOME'],
+ 'Activities/TamTamMini.activity/common/Resources/Sounds/')]
orchlines = []
scorelines = []
instrlist = []
- fnum = [100]
def finddir():
for d in dirs:
@@ -55,9 +55,10 @@ def myblock(tw, sound):
orchlines.append("endin\n\n")
instrlist.append(1)
- scorelines.append("i1 %s %s %s %s %s %s %s\n" % (
- str(starttime), str(duration), str(pitch), str(amplitude),
- str(pitenv), str(ampenv), str(instrument)))
+ scorelines.append("i1 %s %s %s %s %s %s %s\n" %
+ (str(starttime), str(duration), str(pitch),
+ str(amplitude), str(pitenv), str(ampenv),
+ str(instrument)))
def playWave(sound='horse', pitch=1, amplitude=1, loop=False, duration=1,
starttime=0, pitch_envelope='default',
@@ -69,28 +70,35 @@ def myblock(tw, sound):
else:
fullname = finddir() + str(sound)
- if loop == False: lp = 0
- else: lp = 1
+ if loop:
+ lp = 1
+ else:
+ lp = 0
- if pitch_envelope == 'default': pitenv = 99
- else: pitenv = pitch_envelope
+ if pitch_envelope == 'default':
+ pitenv = 99
+ else:
+ pitenv = pitch_envelope
- if amplitude_envelope == 'default': ampenv = 100
- else: ampenv = amplitude_envelope
+ if amplitude_envelope == 'default':
+ ampenv = 100
+ else:
+ ampenv = amplitude_envelope
if not 9 in instrlist:
- orchlines.append("instr 9\n")
+ orchlines.append("instr 9\n")
orchlines.append("kpitenv oscil 1, 1/p3, p8\n")
orchlines.append("aenv oscil 1, 1/p3, p9\n")
- orchlines.append("asig diskin p4, p5*kpitenv, 0, p7\n")
+ orchlines.append("asig diskin p4, p5*kpitenv, 0, p7\n")
orchlines.append("out asig*p6*aenv\n")
orchlines.append("endin\n\n")
instrlist.append(9)
- scorelines.append('i9 %f %f "%s" %s %s %s %s %s\n' % (
- float(starttime), float(duration), fullname, str(pitch),
- str(amplitude), str(lp), str(pitenv), str(ampenv)))
-
+ scorelines.append('i9 %f %f "%s" %s %s %s %s %s\n' %
+ (float(starttime), float(duration), fullname,
+ str(pitch), str(amplitude), str(lp), str(pitenv),
+ str(ampenv)))
+
def audioWrite(file):
""" Compile a .csd file. """
diff --git a/pysamples/forward_push.py b/pysamples/forward_push.py
index f0083b2..b98c726 100644
--- a/pysamples/forward_push.py
+++ b/pysamples/forward_push.py
@@ -50,4 +50,4 @@ def myblock(tw, name):
# Regenerate the palette, which will now include the new block.
tw.show_toolbar_palette(palette_name_to_index('turtle'),
- regenerate=True)
+ regenerate=True)
diff --git a/pysamples/grecord.py b/pysamples/grecord.py
index c53857d..35c7418 100644
--- a/pysamples/grecord.py
+++ b/pysamples/grecord.py
@@ -13,11 +13,7 @@
def myblock(tw, arg):
''' Record and playback a sound (Sugar only) '''
import os
- import time
-
- import gtk
import gst
-
import gobject
gobject.threads_init()
@@ -57,27 +53,29 @@ def myblock(tw, arg):
''' Assemble all the pieces we need. '''
src = gst.element_factory_make("alsasrc", "absrc")
- # attempt to use direct access to the 0,0 device, solving some A/V
- # sync issues
+ # attempt to use direct access to the 0,0 device, solving
+ # some A/V sync issues
src.set_property("device", "plughw:0,0")
hwdev_available = src.set_state(gst.STATE_PAUSED) != \
- gst.STATE_CHANGE_FAILURE
+ gst.STATE_CHANGE_FAILURE
src.set_state(gst.STATE_NULL)
if not hwdev_available:
src.set_property("device", "default")
- srccaps = gst.Caps("audio/x-raw-int,rate=16000,channels=1,depth=16")
+ srccaps = gst.Caps(
+ "audio/x-raw-int,rate=16000,channels=1,depth=16")
# guarantee perfect stream, important for A/V sync
rate = gst.element_factory_make("audiorate")
- # without a buffer here, gstreamer struggles at the start of the
- # recording and then the A/V sync is bad for the whole video
- # (possibly a gstreamer/ALSA bug -- even if it gets caught up, it
- # should be able to resync without problem)
+ # without a buffer here, gstreamer struggles at the start
+ # of the recording and then the A/V sync is bad for the
+ # whole video (possibly a gstreamer/ALSA bug -- even if it
+ # gets caught up, it should be able to resync without
+ # problem)
queue = gst.element_factory_make("queue", "audioqueue")
- queue.set_property("leaky", True) # prefer fresh data
- queue.set_property("max-size-time", 5000000000) # 5 seconds
+ queue.set_property("leaky", True) # prefer fresh data
+ queue.set_property("max-size-time", 5000000000) # 5 seconds
queue.set_property("max-size-buffers", 500)
queue.connect("overrun", self._log_queue_overrun)
@@ -97,7 +95,7 @@ def myblock(tw, arg):
cbuffers = queue.get_property("current-level-buffers")
cbytes = queue.get_property("current-level-bytes")
ctime = queue.get_property("current-level-time")
-
+
def is_recording(self):
''' Are we recording? '''
return self._recording
@@ -120,17 +118,20 @@ def myblock(tw, arg):
self._recording = False
if not os.path.exists(self.capture_file) or \
- os.path.getsize(self.capture_file) <= 0:
+ os.path.getsize(self.capture_file) <= 0:
return
# Remove previous transcoding results.
if os.path.exists(self.save_file):
os.remove(self.save_file)
- line = 'filesrc location=' + self.capture_file + ' name=audioFilesrc ! wavparse name=audioWavparse ! audioconvert name=audioAudioconvert ! vorbisenc name=audioVorbisenc ! oggmux name=audioOggmux ! filesink name=audioFilesink'
+ line = 'filesrc location=' + self.capture_file + \
+ ' name=audioFilesrc ! wavparse name=audioWavparse \
+! audioconvert name=audioAudioconvert ! vorbisenc name=audioVorbisenc \
+! oggmux name=audioOggmux ! filesink name=audioFilesink'
audioline = gst.parse_launch(line)
- vorbis_enc = audioline.get_by_name('audioVorbisenc')
+ # vorbis_enc = audioline.get_by_name('audioVorbisenc')
audioFilesink = audioline.get_by_name('audioFilesink')
audioFilesink.set_property("location", self.save_file)
@@ -203,7 +204,7 @@ def myblock(tw, arg):
# Sometime we need to parse multiple arguments, e.g., save, savename
save_name = '%s_%s' % (tw.activity.name, _('sound'))
- if type(arg) == type([]):
+ if isinstance(arg) == list:
cmd = arg[0].lower()
if len(arg) > 1:
save_name = str(arg[1])
diff --git a/pysamples/journal-stats.py b/pysamples/journal-stats.py
index 2d8a5d3..1342a69 100644
--- a/pysamples/journal-stats.py
+++ b/pysamples/journal-stats.py
@@ -14,15 +14,17 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
def myblock(tw, x): # ignore second argument
''' Load journal stats to heap (Sugar only) '''
import os
import glob
+ from gettext import gettext as _
+
MAX = 19
DIROFINTEREST = 'datastore'
-
class ParseJournal():
''' Simple parser of datastore '''
@@ -78,7 +80,6 @@ def myblock(tw, x): # ignore second argument
activity_list.append([_('other'), count])
return activity_list
-
def hascomponent(path, component):
''' Return metadata attribute, if any '''
if not os.path.exists(os.path.join(path, 'metadata')):
@@ -92,7 +93,6 @@ def myblock(tw, x): # ignore second argument
return False
return data
-
def isactivity(path):
''' Return activity name '''
activity = hascomponent(path, 'activity')
@@ -101,7 +101,6 @@ def myblock(tw, x): # ignore second argument
else:
return activity.split('.')[-1]
-
def isdsdir(path):
''' Only interested if it is a datastore directory '''
if not os.path.isdir(path):
@@ -110,12 +109,11 @@ def myblock(tw, x): # ignore second argument
return False
return True
-
data = ParseJournal()
activity_list = data.get_sorted()
for a in activity_list:
tw.lc.heap.append(a[0])
tw.lc.heap.append(a[1])
-
+
tw.lc.heap.append(activity_list[0][1])
return
diff --git a/pysamples/load_block.py b/pysamples/load_block.py
index 6a6612b..26dc0b2 100644
--- a/pysamples/load_block.py
+++ b/pysamples/load_block.py
@@ -53,12 +53,14 @@ def myblock(tw, blkname):
(1) translate the label name into the internal block name;
(2) 'dock' the block onto a stack where appropriate; and
(3) disassociate the new block from the mouse. """
+
for name in block_names:
# Translate label name into block/prim name.
if blkname in block_names[name]:
- if (name in block_primitives and \
- block_primitives[name] == name) or \
- name in content_blocks:
+ if name in block_primitives and \
+ block_primitives[name] == name:
+ return make_block(tw, name, x, y, defaults)
+ elif name in content_blocks:
return make_block(tw, name, x, y, defaults)
for name in special_names:
# Translate label name into block/prim name.
@@ -69,7 +71,7 @@ def myblock(tw, blkname):
# Place the block at the active turtle (x, y) and move the turtle
# into position to place the next block in the stack.
x, y = tw.active_turtle.get_xy()
- if type(blkname) == type([]):
+ if isinstance(blkname) == list:
name = blkname[0]
value = blkname[1:]
dy = int(find_block(tw, name, x, y, value))
diff --git a/pysamples/push_mouse_event.py b/pysamples/push_mouse_event.py
index b14315c..007c092 100644
--- a/pysamples/push_mouse_event.py
+++ b/pysamples/push_mouse_event.py
@@ -20,7 +20,7 @@ def myblock(tw, x): # ignore second argument
# push y first so x will be popped first
tw.lc.heap.append((tw.canvas.height / 2) - tw.mouse_y)
tw.lc.heap.append(tw.mouse_x - (tw.canvas.width / 2))
- tw.lc.heap.append(1) # mouse event
+ tw.lc.heap.append(1) # mouse event
tw.mouse_flag = 0
else:
- tw.lc.heap.append(0) # no mouse event
+ tw.lc.heap.append(0) # no mouse event
diff --git a/pysamples/serial.py b/pysamples/serial.py
index 153bf90..84772ab 100644
--- a/pysamples/serial.py
+++ b/pysamples/serial.py
@@ -9,13 +9,13 @@
# (3) use a Pop Block to retrieve any strings input from serial device.
-def myblock(tw, x): # x is the string to transmit
- import serial # you may need to install this library
+def myblock(tw, x): # x is the string to transmit
+ import serial # you may need to install this library
- # serial device on USB, 9600 baud
- ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=1)
+ # serial device on USB, 9600 baud
+ ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=1)
- ser.write(str(x)) #send string x
- st = ser.read(1000) #read up to 1000 bytes
- tw.lc.heap.append(st) #append to heap
- ser.close()
+ ser.write(str(x)) # send string x
+ st = ser.read(1000) # read up to 1000 bytes
+ tw.lc.heap.append(st) # append to heap
+ ser.close()
diff --git a/pysamples/svg_end_group.py b/pysamples/svg_end_group.py
index 6b951df..3f5f495 100644
--- a/pysamples/svg_end_group.py
+++ b/pysamples/svg_end_group.py
@@ -17,6 +17,5 @@
def myblock(tw, x):
''' Add end group to SVG output '''
-
- tw.svg_string += '</g>'
+ tw.svg_string += '</g>'
diff --git a/pysamples/svg_start_group.py b/pysamples/svg_start_group.py
index 46da326..e3332bf 100644
--- a/pysamples/svg_start_group.py
+++ b/pysamples/svg_start_group.py
@@ -17,5 +17,5 @@
def myblock(tw, x):
''' Add start group to SVG output '''
-
+
tw.svg_string += '<g>'
diff --git a/pysamples/ta-stats.py b/pysamples/ta-stats.py
index 4d293e6..9a80c04 100644
--- a/pysamples/ta-stats.py
+++ b/pysamples/ta-stats.py
@@ -14,14 +14,14 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
def myblock(tw, x): # ignore second argument
''' Load journal stats to heap (Sugar only) '''
import os
import glob
- MAX = 19
- DIROFINTEREST = 'datastore'
+ _DIROFINTEREST = 'datastore'
class ParseJournal():
''' Simple parser of datastore for turtle art entries '''
@@ -33,20 +33,19 @@ def myblock(tw, x): # ignore second argument
for path in glob.glob(os.path.join(homepath, '.sugar', '*')):
if isdsdir(path):
dsobjdirs = glob.glob(
- os.path.join(path, DIROFINTEREST, '??'))
+ os.path.join(path, _DIROFINTEREST, '??'))
for dsobjdir in dsobjdirs:
dsobjs = glob.glob(os.path.join(dsobjdir, '*'))
for dsobj in dsobjs:
if not isactivity(dsobj) == 'TurtleArtActivity':
continue
if hascomponent(dsobj, 'mime_type') != \
- 'application/x-turtle-art':
+ 'application/x-turtle-art':
continue
score = hasturtleblocks(dsobj)
if score:
self._score.append(score)
-
def hascomponent(path, component):
''' Return metadata attribute, if any '''
if not os.path.exists(os.path.join(path, 'metadata')):
@@ -60,7 +59,6 @@ def myblock(tw, x): # ignore second argument
return False
return data
-
def isactivity(path):
''' Return activity name '''
activity = hascomponent(path, 'activity')
@@ -69,59 +67,59 @@ def myblock(tw, x): # ignore second argument
else:
return activity.split('.')[-1]
-
def isdsdir(path):
''' Only interested if it is a datastore directory '''
if not os.path.isdir(path):
return False
- if not os.path.exists(os.path.join(path, DIROFINTEREST)):
+ if not os.path.exists(os.path.join(path, _DIROFINTEREST)):
return False
return True
-
- TACAT = {'clean':'forward', 'forward':'forward', 'back':'forward',
- 'left':'forward', 'right':'forward', 'arc': 'arc',
- 'xcor': 'coord', 'ycor': 'coord', 'heading': 'coord',
- 'setxy2': 'setxy', 'seth': 'setxy', 'penup': 'pen', 'pendown': 'pen',
- 'setpensize': 'pen', 'setcolor': 'pen', 'pensize': 'pen',
- 'color': 'pen', 'setshade': 'pen', 'setgray': 'pen', 'shade': 'pen',
- 'gray': 'pen', 'fillscreen': 'pen', 'startfill': 'fill',
- 'stopfill': 'fill', 'plus2': 'number', 'minus2': 'number',
- 'product2': 'number', 'division2': 'number', 'remainder2': 'number',
- 'sqrt': 'number', 'identity2': 'number', 'and2': 'boolean',
- 'or2': 'boolean', 'not': 'boolean', 'greater2': 'boolean',
- 'less2': 'boolean', 'equal2': 'boolean', 'random': 'random',
- 'repeat': 'repeat', 'forever': 'repeat', 'if': 'ifthen',
- 'ifelse': 'ifthen', 'while': 'ifthen', 'until': 'ifthen',
- 'hat': 'action', 'stack': 'action', 'storein': 'box', 'box': 'box',
- 'luminance': 'sensor', 'mousex': 'sensor', 'mousey': 'sensor',
- 'mousebutton2': 'sensor', 'keyboard': 'sensor', 'kbinput': 'sensor',
- 'readpixel': 'sensor', 'see': 'sensor', 'time': 'sensor',
- 'sound': 'sensor', 'volume': 'sensor', 'pitch': 'sensor',
- 'resistance': 'sensor', 'voltage': 'sensor', 'video': 'media',
- 'wait': 'media', 'camera': 'media', 'journal': 'media',
- 'audio': 'media', 'show': 'media', 'setscale': 'media',
- 'savepix': 'media', 'savesvg': 'media', 'mediawait': 'media',
- 'mediapause': 'media', 'mediastop': 'media', 'mediaplay': 'media',
- 'speak': 'media', 'sinewave': 'media', 'description': 'media',
- 'push':'extras', 'pop':'extras', 'printheap':'extras',
- 'clearheap':'extras', 'isheapempty2':'extras', 'chr':'extras',
- 'int':'extras', 'myfunction': 'python', 'userdefined': 'python',
- 'loadblock': 'python', 'loadpalette': 'python'}
+ TACAT = {'clean': 'forward', 'forward': 'forward', 'back': 'forward',
+ 'left': 'forward', 'right': 'forward', 'arc': 'arc',
+ 'xcor': 'coord', 'ycor': 'coord', 'heading': 'coord',
+ 'setxy2': 'setxy', 'seth': 'setxy', 'penup': 'pen',
+ 'setpensize': 'pen', 'setcolor': 'pen', 'pensize': 'pen',
+ 'color': 'pen', 'setshade': 'pen', 'setgray': 'pen',
+ 'gray': 'pen', 'fillscreen': 'pen', 'startfill': 'fill',
+ 'stopfill': 'fill', 'plus2': 'number', 'minus2': 'number',
+ 'product2': 'number', 'division2': 'number',
+ 'pendown': 'pen', 'shade': 'pen', 'remainder2': 'number',
+ 'sqrt': 'number', 'identity2': 'number', 'and2': 'boolean',
+ 'or2': 'boolean', 'not': 'boolean', 'greater2': 'boolean',
+ 'less2': 'boolean', 'equal2': 'boolean', 'random': 'random',
+ 'repeat': 'repeat', 'forever': 'repeat', 'if': 'ifthen',
+ 'ifelse': 'ifthen', 'while': 'ifthen', 'until': 'ifthen',
+ 'hat': 'action', 'stack': 'action', 'storein': 'box',
+ 'luminance': 'sensor', 'mousex': 'sensor', 'mousey': 'sensor',
+ 'mousebutton2': 'sensor', 'keyboard': 'sensor',
+ 'readpixel': 'sensor', 'see': 'sensor', 'time': 'sensor',
+ 'sound': 'sensor', 'volume': 'sensor', 'pitch': 'sensor',
+ 'resistance': 'sensor', 'voltage': 'sensor', 'video': 'media',
+ 'wait': 'media', 'camera': 'media', 'journal': 'media',
+ 'audio': 'media', 'show': 'media', 'setscale': 'media',
+ 'savepix': 'media', 'savesvg': 'media', 'mediawait': 'media',
+ 'mediapause': 'media', 'mediastop': 'media', 'mediaplay': 'media',
+ 'speak': 'media', 'sinewave': 'media', 'description': 'media',
+ 'push': 'extras', 'pop': 'extras', 'printheap': 'extras',
+ 'clearheap': 'extras', 'isheapempty2': 'extras', 'chr': 'extras',
+ 'int': 'extras', 'myfunction': 'python', 'userdefined': 'python',
+ 'box': 'box', 'kbinput': 'sensor',
+ 'loadblock': 'python', 'loadpalette': 'python'}
TAPAL = {'forward': 'turtlep', 'arc': 'turtlep', 'coord': 'turtlep',
- 'setxy': 'turtlep', 'pen': 'penp', 'fill': 'penp', 'number': 'numberp',
- 'random': 'numberp', 'boolean': 'numberp', 'repeat': 'flowp',
- 'ifthen': 'flowp', 'action': 'boxp', 'box': 'boxp',
- 'sensor': 'sensorp', 'media': 'mediap', 'extras': 'extrasp',
- 'python': 'extrasp'}
+ 'setxy': 'turtlep', 'pen': 'penp', 'fill': 'penp',
+ 'random': 'numberp', 'boolean': 'numberp', 'repeat': 'flowp',
+ 'ifthen': 'flowp', 'action': 'boxp', 'box': 'boxp',
+ 'sensor': 'sensorp', 'media': 'mediap', 'extras': 'extrasp',
+ 'number': 'numberp', 'python': 'extrasp'}
TASCORE = {'forward': 3, 'arc': 3, 'setxy': 2.5, 'coord': 4, 'turtlep': 5,
- 'pen': 2.5, 'fill': 2.5, 'penp': 5,
- 'number': 2.5, 'boolean': 2.5, 'random': 2.5, 'numberp': 0,
- 'repeat': 2.5, 'ifthen': 7.5, 'flowp': 10,
- 'box': 7.5, 'action': 7.5, 'boxp': 0,
- 'media': 5, 'mediap': 0,
- 'python': 5, 'extras': 5, 'extrasp': 0,
- 'sensor': 5, 'sensorp': 0}
+ 'pen': 2.5, 'fill': 2.5, 'penp': 5,
+ 'number': 2.5, 'boolean': 2.5, 'random': 2.5, 'numberp': 0,
+ 'repeat': 2.5, 'ifthen': 7.5, 'flowp': 10,
+ 'box': 7.5, 'action': 7.5, 'boxp': 0,
+ 'media': 5, 'mediap': 0,
+ 'python': 5, 'extras': 5, 'extrasp': 0,
+ 'sensor': 5, 'sensorp': 0}
PALS = ['turtlep', 'penp', 'numberp', 'flowp', 'boxp', 'sensorp', 'mediap',
'extrasp']
@@ -169,6 +167,6 @@ def myblock(tw, x): # ignore second argument
for i in range(n):
for j in range(len(PALS)):
tw.lc.heap.append(data._score[(n - i - 1)][len(PALS) - j - 1])
-
+
tw.lc.heap.append(n)
return
diff --git a/pysamples/uturn.py b/pysamples/uturn.py
index 0b164a0..cdeb96d 100644
--- a/pysamples/uturn.py
+++ b/pysamples/uturn.py
@@ -27,9 +27,9 @@ def myblock(tw, arg):
# Add its primitive to the LogoCode dictionary.
tw.lc.def_prim('uturn', 0,
- lambda self: primitive_dictionary['set'](
- 'heading', tw.canvas.seth, tw.canvas.heading + 180))
+ lambda self: primitive_dictionary['set']
+ ('heading', tw.canvas.seth, tw.canvas.heading + 180))
# Regenerate the palette, which will now include the new block.
tw.show_toolbar_palette(palette_name_to_index('turtle'),
- regenerate=True)
+ regenerate=True)