From 235845313fb283fcafd050fae5559220de8883ec Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Sat, 05 Mar 2011 15:00:24 +0000 Subject: renamed PLUGIN_DICTIONARY to more descriptive primitive_dictionary --- diff --git a/TurtleArt/tabasics.py b/TurtleArt/tabasics.py index 685c063..e9d01e9 100644 --- a/TurtleArt/tabasics.py +++ b/TurtleArt/tabasics.py @@ -65,7 +65,7 @@ from random import uniform from gettext import gettext as _ from tapalette import make_palette -from talogo import PLUGIN_DICTIONARY, logoerror +from talogo import primitive_dictionary, logoerror from taconstants import CONSTANTS, BLACK, WHITE from tautils import convert, chr_to_ord, round_int, strtype @@ -115,7 +115,7 @@ class Palettes(): colors=["#00FF00", "#00A000"], help_string=_('Palette of turtle commands')) - PLUGIN_DICTIONARY['move'] = self._prim_move + primitive_dictionary['move'] = self._prim_move palette.add_block('forward', style='basic-style-1arg', label=_('forward'), @@ -123,7 +123,7 @@ class Palettes(): prim_name='forward', help_string=_('moves turtle forward')) self.tw.lc.def_prim('forward', 1, - lambda self, x: PLUGIN_DICTIONARY['move']( + lambda self, x: primitive_dictionary['move']( self.tw.canvas.forward, x)) palette.add_block('back', @@ -133,10 +133,10 @@ class Palettes(): default=100, help_string=_('moves turtle backward')) self.tw.lc.def_prim('back', 1, - lambda self, x: PLUGIN_DICTIONARY['move']( + lambda self, x: primitive_dictionary['move']( self.tw.canvas.forward, -x)) - PLUGIN_DICTIONARY['clean'] = self.tw.lc.prim_clear + primitive_dictionary['clean'] = self.tw.lc.prim_clear palette.add_block('clean', style='basic-style-extended-vertical', label=_('clean'), @@ -144,9 +144,9 @@ class Palettes(): help_string=_('clears the screen and reset the \ turtle')) self.tw.lc.def_prim('clean', 0, - lambda self: PLUGIN_DICTIONARY['clean']()) + lambda self: primitive_dictionary['clean']()) - PLUGIN_DICTIONARY['right'] = self._prim_right + primitive_dictionary['right'] = self._prim_right palette.add_block('left', style='basic-style-1arg', label=_('left'), @@ -155,7 +155,7 @@ turtle')) help_string=_('turns turtle counterclockwise (angle \ in degrees)')) self.tw.lc.def_prim('right', 1, - lambda self, x: PLUGIN_DICTIONARY['right'](-x)) + lambda self, x: primitive_dictionary['right'](-x)) palette.add_block('right', style='basic-style-1arg', @@ -165,9 +165,9 @@ in degrees)')) help_string=_('turns turtle clockwise (angle in \ degrees)')) self.tw.lc.def_prim('right', 1, - lambda self, x: PLUGIN_DICTIONARY['right'](x)) + lambda self, x: primitive_dictionary['right'](x)) - PLUGIN_DICTIONARY['arc'] = self._prim_arc + primitive_dictionary['arc'] = self._prim_arc palette.add_block('arc', style='basic-style-2arg', label=[_('arc'), _('angle'), _('radius')], @@ -175,7 +175,7 @@ degrees)')) default=[90, 100], help_string=_('moves turtle along an arc')) self.tw.lc.def_prim('arc', 2, - lambda self, x, y: PLUGIN_DICTIONARY['arc']( + lambda self, x, y: primitive_dictionary['arc']( self.tw.canvas.arc, x, y)) palette.add_block('setxy2', @@ -186,10 +186,10 @@ degrees)')) help_string=_('moves turtle to position xcor, ycor; \ (0, 0) is in the center of the screen.')) self.tw.lc.def_prim('setxy2', 2, - lambda self, x, y: PLUGIN_DICTIONARY['move']( + lambda self, x, y: primitive_dictionary['move']( self.tw.canvas.setxy, x, y)) - PLUGIN_DICTIONARY['set'] = self._prim_set + primitive_dictionary['set'] = self._prim_set palette.add_block('seth', style='basic-style-1arg', label=_('set heading'), @@ -198,7 +198,7 @@ degrees)')) help_string=_('sets the heading of the turtle (0 is \ towards the top of the screen.)')) self.tw.lc.def_prim('seth', 1, - lambda self, x: PLUGIN_DICTIONARY['set']( + lambda self, x: primitive_dictionary['set']( 'heading', self.tw.canvas.seth, x)) palette.add_block('xcor', @@ -241,7 +241,7 @@ turtle (can be used in place of a number block)'), help_string=_('moves turtle to position xcor, ycor; \ (0, 0) is in the center of the screen.')) self.tw.lc.def_prim('setxy', 2, - lambda self, x, y: PLUGIN_DICTIONARY['move']( + lambda self, x, y: primitive_dictionary['move']( self.tw.canvas.setxy, x, y, pendown=False)) def _pen_palette(self): @@ -275,7 +275,7 @@ turtle (can be used in place of a number block)'), help_string=_('sets size of the line drawn by the \ turtle')) self.tw.lc.def_prim('setpensize', 1, - lambda self, x: PLUGIN_DICTIONARY['set']( + lambda self, x: primitive_dictionary['set']( 'pensize', self.tw.canvas.setpensize, x)) palette.add_block('fillscreen', @@ -330,7 +330,7 @@ start fill block)')) help_string=_('sets color of the line drawn by the \ turtle')) self.tw.lc.def_prim('setcolor', 1, - lambda self, x: PLUGIN_DICTIONARY['set']( + lambda self, x: primitive_dictionary['set']( 'color', self.tw.canvas.setcolor, x)) palette.add_block('setshade', @@ -341,7 +341,7 @@ turtle')) help_string=_('sets shade of the line drawn by the \ turtle')) self.tw.lc.def_prim('setshade', 1, - lambda self, x: PLUGIN_DICTIONARY['set']( + lambda self, x: primitive_dictionary['set']( 'shade', self.tw.canvas.setshade, x)) palette.add_block('setgray', @@ -352,7 +352,7 @@ turtle')) help_string=_('sets gray level of the line drawn by \ the turtle')) self.tw.lc.def_prim('setgray', 1, - lambda self, x: PLUGIN_DICTIONARY['set']( + lambda self, x: primitive_dictionary['set']( 'gray', self.tw.canvas.setgray, x)) palette.add_block('color', @@ -421,7 +421,7 @@ turtle')) colors=["#FF00FF", "#A000A0"], help_string=_('Palette of numeric operators')) - PLUGIN_DICTIONARY['plus'] = self._prim_plus + primitive_dictionary['plus'] = self._prim_plus palette.add_block('plus2', style='number-style', label='+', @@ -429,9 +429,9 @@ turtle')) prim_name='plus', help_string=_('adds two alphanumeric inputs')) self.tw.lc.def_prim( - 'plus', 2, lambda self, x, y: PLUGIN_DICTIONARY['plus'](x, y)) + 'plus', 2, lambda self, x, y: primitive_dictionary['plus'](x, y)) - PLUGIN_DICTIONARY['minus'] = self._prim_minus + primitive_dictionary['minus'] = self._prim_minus palette.add_block('minus2', style='number-style-porch', label='–', @@ -440,9 +440,9 @@ turtle')) help_string=_('subtracts bottom numeric input from \ top numeric input')) self.tw.lc.def_prim( - 'minus', 2, lambda self, x, y: PLUGIN_DICTIONARY['minus'](x, y)) + 'minus', 2, lambda self, x, y: primitive_dictionary['minus'](x, y)) - PLUGIN_DICTIONARY['product'] = self._prim_product + primitive_dictionary['product'] = self._prim_product palette.add_block('product2', style='number-style', label='×', @@ -451,9 +451,9 @@ top numeric input')) help_string=_('multiplies two numeric inputs')) self.tw.lc.def_prim( 'product', 2, - lambda self, x, y: PLUGIN_DICTIONARY['product'](x, y)) + lambda self, x, y: primitive_dictionary['product'](x, y)) - PLUGIN_DICTIONARY['division'] = self._prim_careful_divide + primitive_dictionary['division'] = self._prim_careful_divide palette.add_block('division2', style='number-style-porch', label='/', @@ -463,9 +463,9 @@ top numeric input')) by bottom numeric input (denominator)')) self.tw.lc.def_prim( 'division', 2, - lambda self, x, y: PLUGIN_DICTIONARY['division'](x, y)) + lambda self, x, y: primitive_dictionary['division'](x, y)) - PLUGIN_DICTIONARY['id'] = self._prim_identity + primitive_dictionary['id'] = self._prim_identity palette.add_block('identity2', style='number-style-1strarg', label='←', @@ -474,9 +474,9 @@ by bottom numeric input (denominator)')) help_string=_('identity operator used for extending \ blocks')) self.tw.lc.def_prim('id', 1, - lambda self, x: PLUGIN_DICTIONARY['id'](x)) + lambda self, x: primitive_dictionary['id'](x)) - PLUGIN_DICTIONARY['remainder'] = self._prim_mod + primitive_dictionary['remainder'] = self._prim_mod palette.add_block('remainder2', style='number-style-porch', label=_('mod'), @@ -484,9 +484,9 @@ blocks')) prim_name='remainder', help_string=_('modular (remainder) operator')) self.tw.lc.def_prim('remainder', 2, - lambda self, x, y: PLUGIN_DICTIONARY['remainder'](x, y)) + lambda self, x, y: primitive_dictionary['remainder'](x, y)) - PLUGIN_DICTIONARY['sqrt'] = self._prim_sqrt + primitive_dictionary['sqrt'] = self._prim_sqrt palette.add_block('sqrt', style='number-style-1arg', label=_('√'), @@ -494,9 +494,9 @@ blocks')) prim_name='sqrt', help_string=_('calculates square root')) self.tw.lc.def_prim('sqrt', 1, - lambda self, x: PLUGIN_DICTIONARY['sqrt'](x)) + lambda self, x: primitive_dictionary['sqrt'](x)) - PLUGIN_DICTIONARY['random'] = self._prim_random + primitive_dictionary['random'] = self._prim_random palette.add_block('random', style='number-style-block', label=[_('random'), _('min'), _('max')], @@ -505,7 +505,7 @@ blocks')) help_string=_('returns random number between minimum \ (top) and maximum (bottom) values')) self.tw.lc.def_prim( - 'random', 2, lambda self, x, y: PLUGIN_DICTIONARY['random'](x, y)) + 'random', 2, lambda self, x, y: primitive_dictionary['random'](x, y)) palette.add_block('number', style='box-style', @@ -515,7 +515,7 @@ blocks')) help_string=_('used as numeric input in mathematic \ operators')) - PLUGIN_DICTIONARY['more'] = self._prim_more + primitive_dictionary['more'] = self._prim_more palette.add_block('greater2', style='compare-porch-style', label='>', @@ -523,9 +523,9 @@ operators')) prim_name='greater?', help_string=_('logical greater-than operator')) self.tw.lc.def_prim( - 'greater?', 2, lambda self, x, y: PLUGIN_DICTIONARY['more'](x, y)) + 'greater?', 2, lambda self, x, y: primitive_dictionary['more'](x, y)) - PLUGIN_DICTIONARY['less'] = self._prim_less + primitive_dictionary['less'] = self._prim_less palette.add_block('less2', style='compare-porch-style', label='<', @@ -533,9 +533,9 @@ operators')) prim_name='less?', help_string=_('logical less-than operator')) self.tw.lc.def_prim( - 'less?', 2, lambda self, x, y: PLUGIN_DICTIONARY['less'](x, y)) + 'less?', 2, lambda self, x, y: primitive_dictionary['less'](x, y)) - PLUGIN_DICTIONARY['equal'] = self._prim_equal + primitive_dictionary['equal'] = self._prim_equal palette.add_block('equal2', style='compare-style', label='=', @@ -543,7 +543,7 @@ operators')) prim_name='equal?', help_string=_('logical equal-to operator')) self.tw.lc.def_prim( - 'equal?', 2, lambda self, x, y: PLUGIN_DICTIONARY['equal'](x, y)) + 'equal?', 2, lambda self, x, y: primitive_dictionary['equal'](x, y)) palette.add_block('not', style='not-style', @@ -575,7 +575,7 @@ operators')) colors=["#FFC000", "#A08000"], help_string=_('Palette of flow operators')) - PLUGIN_DICTIONARY['wait'] = self._prim_wait + primitive_dictionary['wait'] = self._prim_wait palette.add_block('wait', style='basic-style-1arg', label=_('wait'), @@ -583,18 +583,18 @@ operators')) default=1, help_string=_('pauses program execution a specified \ number of seconds')) - self.tw.lc.def_prim('wait', 1, PLUGIN_DICTIONARY['wait'], True) + self.tw.lc.def_prim('wait', 1, primitive_dictionary['wait'], True) - PLUGIN_DICTIONARY['forever'] = self._prim_forever + primitive_dictionary['forever'] = self._prim_forever palette.add_block('forever', style='flow-style', label=_('forever'), prim_name='forever', default=[None, 'vspace'], help_string=_('loops forever')) - self.tw.lc.def_prim('forever', 1, PLUGIN_DICTIONARY['forever'], True) + self.tw.lc.def_prim('forever', 1, primitive_dictionary['forever'], True) - PLUGIN_DICTIONARY['repeat'] = self._prim_repeat + primitive_dictionary['repeat'] = self._prim_repeat palette.add_block('repeat', style='flow-style-1arg', label=[' ', _('repeat')], @@ -602,9 +602,9 @@ number of seconds')) default=[4, None, 'vspace'], special_name=_('repeat'), help_string=_('loops specified number of times')) - self.tw.lc.def_prim('repeat', 2, PLUGIN_DICTIONARY['repeat'], True) + self.tw.lc.def_prim('repeat', 2, primitive_dictionary['repeat'], True) - PLUGIN_DICTIONARY['if'] = self._prim_if + primitive_dictionary['if'] = self._prim_if palette.add_block('if', style='flow-style-boolean', label=[' ', _('if'), _('then')], @@ -613,9 +613,9 @@ number of seconds')) special_name=_('if then'), help_string=_('if-then operator that uses boolean \ operators from Numbers palette')) - self.tw.lc.def_prim('if', 2, PLUGIN_DICTIONARY['if'], True) + self.tw.lc.def_prim('if', 2, primitive_dictionary['if'], True) - PLUGIN_DICTIONARY['ifelse'] = self._prim_ifelse + primitive_dictionary['ifelse'] = self._prim_ifelse palette.add_block('ifelse', style='flow-style-else', label=[' ', _('if'), _('then else')], @@ -624,7 +624,7 @@ operators from Numbers palette')) special_name=_('if then else'), help_string=_('if-then-else operator that uses \ boolean operators from Numbers palette')) - self.tw.lc.def_prim('ifelse', 3, PLUGIN_DICTIONARY['ifelse'], True) + self.tw.lc.def_prim('ifelse', 3, primitive_dictionary['ifelse'], True) palette.add_block('hspace', style='flow-style-tail', @@ -642,14 +642,14 @@ boolean operators from Numbers palette')) help_string=_('jogs stack down')) self.tw.lc.def_prim('nop', 0, lambda self: None) - PLUGIN_DICTIONARY['stopstack'] = self._prim_stopstack + primitive_dictionary['stopstack'] = self._prim_stopstack palette.add_block('stopstack', style='basic-style-tail', label=_('stop action'), prim_name='stopstack', help_string=_('stops current action')) self.tw.lc.def_prim('stopstack', 0, - lambda self: PLUGIN_DICTIONARY['stopstack']()) + lambda self: primitive_dictionary['stopstack']()) def _blocks_palette(self): """ The basic Turtle Art blocks palette """ @@ -658,7 +658,7 @@ boolean operators from Numbers palette')) colors=["#FFFF00", "#A0A000"], help_string=_('Palette of variable blocks')) - PLUGIN_DICTIONARY['start'] = self._prim_start + primitive_dictionary['start'] = self._prim_start palette.add_block('start', style='basic-style-head', label=_('start'), @@ -666,9 +666,9 @@ boolean operators from Numbers palette')) help_string=_('connects action to toolbar run \ buttons')) self.tw.lc.def_prim('start', 0, - lambda self: PLUGIN_DICTIONARY['start']()) + lambda self: primitive_dictionary['start']()) - PLUGIN_DICTIONARY['setbox'] = self._prim_setbox + primitive_dictionary['setbox'] = self._prim_setbox palette.add_block('storeinbox1', style='basic-style-1arg', label=_('store in box 1'), @@ -676,7 +676,7 @@ buttons')) default=100, help_string=_('stores numeric value in Variable 1')) self.tw.lc.def_prim('storeinbox1', 1, - lambda self, x: PLUGIN_DICTIONARY['setbox']( + lambda self, x: primitive_dictionary['setbox']( 'box1', None, x)) palette.add_block('storeinbox2', @@ -686,7 +686,7 @@ buttons')) default=100, help_string=_('stores numeric value in Variable 2')) self.tw.lc.def_prim('storeinbox2', 1, - lambda self, x: PLUGIN_DICTIONARY['setbox']( + lambda self, x: primitive_dictionary['setbox']( 'box2', None, x)) palette.add_block('string', @@ -712,7 +712,7 @@ buttons')) value_block=True) self.tw.lc.def_prim('box2', 0, lambda self: self.tw.lc.boxes['box2']) - PLUGIN_DICTIONARY['box'] = self._prim_box + primitive_dictionary['box'] = self._prim_box palette.add_block('box', style='number-style-1strarg', label=_('box'), @@ -720,7 +720,7 @@ buttons')) default=_('my box'), help_string=_('named variable (numeric value)')) self.tw.lc.def_prim('box', 1, - lambda self, x: PLUGIN_DICTIONARY['box'](x)) + lambda self, x: primitive_dictionary['box'](x)) palette.add_block('storein', style='basic-style-2arg', @@ -730,7 +730,7 @@ buttons')) help_string=_('stores numeric value in named \ variable')) self.tw.lc.def_prim('storeinbox', 2, - lambda self, x, y: PLUGIN_DICTIONARY['setbox']( + lambda self, x, y: primitive_dictionary['setbox']( 'box3', x, y)) palette.add_block('hat', @@ -755,32 +755,32 @@ variable')) help_string=_('top of Action 2 stack')) self.tw.lc.def_prim('nop2', 0, lambda self: None) - PLUGIN_DICTIONARY['stack'] = self._prim_stack + primitive_dictionary['stack'] = self._prim_stack palette.add_block('stack', style='basic-style-1arg', label=_('action'), prim_name='stack', default=_('action'), help_string=_('invokes named action stack')) - self.tw.lc.def_prim('stack', 1, PLUGIN_DICTIONARY['stack'], True) + self.tw.lc.def_prim('stack', 1, primitive_dictionary['stack'], True) - PLUGIN_DICTIONARY['stack1'] = self._prim_stack1 + primitive_dictionary['stack1'] = self._prim_stack1 palette.add_block('stack1', style='basic-style-extended-vertical', label=_('action 1'), prim_name='stack1', default=_('action 1'), help_string=_('invokes Action 1 stack')) - self.tw.lc.def_prim('stack1', 0, PLUGIN_DICTIONARY['stack1'], True) + self.tw.lc.def_prim('stack1', 0, primitive_dictionary['stack1'], True) - PLUGIN_DICTIONARY['stack2'] = self._prim_stack2 + primitive_dictionary['stack2'] = self._prim_stack2 palette.add_block('stack2', style='basic-style-extended-vertical', label=_('action 2'), prim_name='stack2', default=_('action 2'), help_string=_('invokes Action 2 stack')) - self.tw.lc.def_prim('stack2', 0, PLUGIN_DICTIONARY['stack2'], True) + self.tw.lc.def_prim('stack2', 0, primitive_dictionary['stack2'], True) def _trash_palette(self): """ The basic Turtle Art turtle palette """ diff --git a/TurtleArt/talogo.py b/TurtleArt/talogo.py index aeb36f4..a623211 100644 --- a/TurtleArt/talogo.py +++ b/TurtleArt/talogo.py @@ -36,9 +36,9 @@ from util.RtfParser import RtfTextOnly from gettext import gettext as _ -VALUE_BLOCKS = [] # blocks whose labels are updated get added here -MEDIA_BLOCKS_DICTIONARY = {} # new media blocks get added here -PLUGIN_DICTIONARY = {} # new block primitives get added here +value_blocks = [] # blocks whose labels are updated get added here +media_blocks_dictionary = {} # new media blocks get added here +primitive_dictionary = {} # new block primitives get added here class noKeyError(UserDict): @@ -232,7 +232,7 @@ class LogoCode: str(blk.values[0])) else: code.append(PREFIX_DICTIONARY[blk.name] + 'None') - elif blk.name in MEDIA_BLOCKS_DICTIONARY: + elif blk.name in media_blocks_dictionary: code.append('#smedia_' + blk.name.upper()) else: return ['%nothing%'] @@ -499,7 +499,7 @@ class LogoCode: self.tw.lc.scale = DEFAULT_SCALE self.tw.lc.hidden_turtle = None self.tw.lc.start_time = time() - for name in VALUE_BLOCKS: + for name in value_blocks: self.tw.lc.update_label_value(name) def int(self, n): @@ -516,10 +516,10 @@ class LogoCode: def find_value_blocks(self): """ Find any value blocks that may need label updates """ - self.value_blocks = {} - for name in VALUE_BLOCKS: - self.value_blocks[name] = self.tw.block_list.get_similar_blocks( - 'block', name) + self.value_blocks_to_update = {} + for name in value_blocks: + self.value_blocks_to_update[name] = \ + self.tw.block_list.get_similar_blocks('block', name) def update_label_value(self, name, value=None): """ Update the label of value blocks to reflect current value """ @@ -527,7 +527,7 @@ class LogoCode: not hasattr(self, 'value_blocks'): return if value is None: - for block in self.value_blocks[name]: + for block in self.value_blocks_to_update[name]: block.spr.set_label(BLOCK_NAMES[name][0]) block.resize() elif self.update_values: @@ -536,7 +536,7 @@ class LogoCode: self.tw.decimal_point) else: valstring = str(value) - for block in self.value_blocks[name]: + for block in self.value_blocks_to_update[name]: block.spr.set_label(BLOCK_NAMES[name][0] + ' = ' + valstring) block.resize() diff --git a/TurtleArt/tapalette.py b/TurtleArt/tapalette.py index 7eea957..4f84da3 100644 --- a/TurtleArt/tapalette.py +++ b/TurtleArt/tapalette.py @@ -22,7 +22,7 @@ from taconstants import BLOCK_STYLES, BLOCK_NAMES, HELP_STRINGS, PALETTES, \ PALETTE_NAMES, CONTENT_BLOCKS, PRIMITIVES, DEFAULTS, SPECIAL_NAMES, \ COLORS, EXPANDABLE_STYLE, EXPANDABLE_BLOCKS -from talogo import VALUE_BLOCKS +from talogo import value_blocks from tautils import debug_output @@ -154,7 +154,7 @@ class Block(): HELP_STRINGS[self._name] = '' if self._value_block: - VALUE_BLOCKS.append(self._name) + value_blocks.append(self._name) if self._content_block: CONTENT_BLOCKS.append(self._name) diff --git a/plugins/audio_sensors_plugin.py b/plugins/audio_sensors_plugin.py index bbc0ab9..a058ed8 100644 --- a/plugins/audio_sensors_plugin.py +++ b/plugins/audio_sensors_plugin.py @@ -33,7 +33,7 @@ from audio.ringbuffer import RingBuffer1d from TurtleArt.tapalette import make_palette from TurtleArt.taconstants import XO1, XO15 -from TurtleArt.talogo import PLUGIN_DICTIONARY +from TurtleArt.talogo import primitive_dictionary import logging _logger = logging.getLogger('turtleart-activity audio sensors plugin') @@ -81,7 +81,7 @@ class Audio_sensors_plugin(Plugin): colors=["#FF6060", "#A06060"], help_string=_('Palette of sensor blocks')) - PLUGIN_DICTIONARY['sound'] = self.prim_sound + primitive_dictionary['sound'] = self.prim_sound palette.add_block('sound', style='box-style', label=_('sound'), @@ -89,9 +89,9 @@ class Audio_sensors_plugin(Plugin): value_block=True, prim_name='sound') self._parent.lc.def_prim('sound', 0, - lambda self: PLUGIN_DICTIONARY['sound']()) + lambda self: primitive_dictionary['sound']()) - PLUGIN_DICTIONARY['volume'] = self.prim_volume + primitive_dictionary['volume'] = self.prim_volume palette.add_block('volume', style='box-style', label=_('loudness'), @@ -99,9 +99,9 @@ class Audio_sensors_plugin(Plugin): value_block=True, prim_name='volume') self._parent.lc.def_prim('volume', 0, - lambda self: PLUGIN_DICTIONARY['volume']()) + lambda self: primitive_dictionary['volume']()) - PLUGIN_DICTIONARY['pitch'] = self.prim_pitch + primitive_dictionary['pitch'] = self.prim_pitch if PITCH_AVAILABLE: palette.add_block('pitch', style='box-style', @@ -118,10 +118,10 @@ class Audio_sensors_plugin(Plugin): value_block=True, prim_name='pitch') self._parent.lc.def_prim('pitch', 0, - lambda self: PLUGIN_DICTIONARY['pitch']()) + lambda self: primitive_dictionary['pitch']()) if self.hw in [XO1, XO15]: - PLUGIN_DICTIONARY['resistance'] = self.prim_resistance + primitive_dictionary['resistance'] = self.prim_resistance palette.add_block('resistance', style='box-style', label=_('resistance'), @@ -129,9 +129,9 @@ class Audio_sensors_plugin(Plugin): value_block=True, prim_name='resistance') self._parent.lc.def_prim('resistance', 0, - lambda self: PLUGIN_DICTIONARY['resistance']()) + lambda self: primitive_dictionary['resistance']()) - PLUGIN_DICTIONARY['voltage'] = self.prim_voltage + primitive_dictionary['voltage'] = self.prim_voltage palette.add_block('voltage', style='box-style', label=_('voltage'), @@ -139,7 +139,7 @@ class Audio_sensors_plugin(Plugin): value_block=True, prim_name='voltage') self._parent.lc.def_prim('voltage', 0, - lambda self: PLUGIN_DICTIONARY['voltage']()) + lambda self: primitive_dictionary['voltage']()) self.audio_started = False diff --git a/plugins/camera_plugin.py b/plugins/camera_plugin.py index e1e0f61..7cd045b 100644 --- a/plugins/camera_plugin.py +++ b/plugins/camera_plugin.py @@ -28,7 +28,7 @@ from camera.v4l2 import v4l2_control, V4L2_CID_AUTOGAIN, VIDIOC_G_CTRL, \ from plugin import Plugin from TurtleArt.tapalette import make_palette -from TurtleArt.talogo import MEDIA_BLOCKS_DICTIONARY, PLUGIN_DICTIONARY +from TurtleArt.talogo import media_blocks_dictionary, primitive_dictionary from TurtleArt.tautils import get_path import logging @@ -60,7 +60,7 @@ class Camera_plugin(Plugin): # set up camera-specific blocks if self._status: - PLUGIN_DICTIONARY['luminance'] = self.prim_read_camera + primitive_dictionary['luminance'] = self.prim_read_camera palette.add_block('luminance', style='box-style', label=_('brightness'), @@ -68,10 +68,10 @@ class Camera_plugin(Plugin): value_block=True, prim_name='luminance') self._parent.lc.def_prim('luminance', 0, - lambda self: PLUGIN_DICTIONARY['luminance'](True)) + lambda self: primitive_dictionary['luminance'](True)) # Depreciated block - PLUGIN_DICTIONARY['read_camera'] = self.prim_read_camera + primitive_dictionary['read_camera'] = self.prim_read_camera palette.add_block('read_camera', hidden=True, style='box-style', @@ -81,9 +81,9 @@ is pushed to the stack'), value_block=True, prim_name='luminance') self._parent.lc.def_prim('read_camera', 0, - lambda self: PLUGIN_DICTIONARY['read_camera'](True)) + lambda self: primitive_dictionary['read_camera'](True)) - MEDIA_BLOCKS_DICTIONARY['camera'] = self.prim_take_picture + media_blocks_dictionary['camera'] = self.prim_take_picture palette.add_block('camera', style='box-style-media', label=' ', diff --git a/plugins/rfid_plugin.py b/plugins/rfid_plugin.py index 76f5ee9..a620587 100644 --- a/plugins/rfid_plugin.py +++ b/plugins/rfid_plugin.py @@ -26,7 +26,7 @@ from rfid.rfidutils import strhex2bin, strbin2dec, find_device from plugin import Plugin from TurtleArt.tapalette import make_palette -from TurtleArt.talogo import PLUGIN_DICTIONARY +from TurtleArt.talogo import primitive_dictionary import logging _logger = logging.getLogger('turtleart-activity RFID plugin') @@ -86,7 +86,7 @@ class Rfid_plugin(Plugin): colors=["#FF6060", "#A06060"], help_string=_('Palette of sensor blocks')) - PLUGIN_DICTIONARY['rfid'] = self.prim_read_camera + primitive_dictionary['rfid'] = self.prim_read_camera palette.add_block('rfid', palette='sensor', style='box-style', @@ -95,7 +95,7 @@ class Rfid_plugin(Plugin): value_block=True, prim_name='rfid') self._parent.lc.def_prim('rfid', 0, - lambda self: PLUGIN_DICTIONARY['rfid'](True)) + lambda self: primitive_dictionary['rfid'](True)) def _status_report(self): print 'Reporting RFID status: %s' % (str(self._status)) diff --git a/plugins/turtle_blocks_plugin.py b/plugins/turtle_blocks_plugin.py index c47957b..85a25b7 100644 --- a/plugins/turtle_blocks_plugin.py +++ b/plugins/turtle_blocks_plugin.py @@ -27,8 +27,8 @@ except ImportError: from plugin import Plugin from TurtleArt.tapalette import make_palette -from TurtleArt.talogo import PLUGIN_DICTIONARY, logoerror, \ - MEDIA_BLOCKS_DICTIONARY +from TurtleArt.talogo import primitive_dictionary, logoerror, \ + media_blocks_dictionary from TurtleArt.taconstants import DEFAULT_SCALE, CONSTANTS, ICON_SIZE from TurtleArt.tautils import convert, round_int, debug_output from TurtleArt.tajail import myfunc, myfunc_import @@ -147,7 +147,7 @@ boolean operators from Numbers palette')) special_name='', help_string=_('string value')) - PLUGIN_DICTIONARY['show'] = self._prim_show + primitive_dictionary['show'] = self._prim_show palette.add_block('show', style='basic-style-1arg', label=_('show'), @@ -156,7 +156,7 @@ boolean operators from Numbers palette')) help_string=_('draws text or show media from the \ Journal')) self.tw.lc.def_prim('show', 1, - lambda self, x: PLUGIN_DICTIONARY['show'](x, True)) + lambda self, x: primitive_dictionary['show'](x, True)) palette.add_block('showaligned', hidden=True, @@ -167,10 +167,10 @@ Journal')) help_string=_('draws text or show media from the \ Journal')) self.tw.lc.def_prim('showaligned', 1, - lambda self, x: PLUGIN_DICTIONARY['show'](x, False)) + lambda self, x: primitive_dictionary['show'](x, False)) # deprecated - PLUGIN_DICTIONARY['write'] = self._prim_write + primitive_dictionary['write'] = self._prim_write palette.add_block('write', hidden=True, style='basic-style-1arg', @@ -180,9 +180,9 @@ Journal')) help_string=_('draws text or show media from the \ Journal')) self.tw.lc.def_prim('write', 2, - lambda self, x, y: PLUGIN_DICTIONARY['write'](x, y)) + lambda self, x, y: primitive_dictionary['write'](x, y)) - PLUGIN_DICTIONARY['setscale'] = self._prim_setscale + primitive_dictionary['setscale'] = self._prim_setscale palette.add_block('setscale', style='basic-style-1arg', label=_('set scale'), @@ -190,9 +190,9 @@ Journal')) default=33, help_string=_('sets the scale of media')) self.tw.lc.def_prim('setscale', 1, - lambda self, x: PLUGIN_DICTIONARY['setscale'](x)) + lambda self, x: primitive_dictionary['setscale'](x)) - PLUGIN_DICTIONARY['savepix'] = self._prim_save_picture + primitive_dictionary['savepix'] = self._prim_save_picture palette.add_block('savepix', style='basic-style-1arg', label=_('save picture'), @@ -200,9 +200,9 @@ Journal')) default=_('picture name'), help_string=_('saves a picture to the Sugar Journal')) self.tw.lc.def_prim('savepix', 1, - lambda self, x: PLUGIN_DICTIONARY['savepix'](x)) + lambda self, x: primitive_dictionary['savepix'](x)) - PLUGIN_DICTIONARY['savesvg'] = self._prim_save_svg + primitive_dictionary['savesvg'] = self._prim_save_svg palette.add_block('savesvg', style='basic-style-1arg', label=_('save SVG'), @@ -211,7 +211,7 @@ Journal')) help_string=_('saves turtle graphics as an SVG file \ in the Sugar Journal')) self.tw.lc.def_prim('savesvg', 1, - lambda self, x: PLUGIN_DICTIONARY['savesvg'](x)) + lambda self, x: primitive_dictionary['savesvg'](x)) palette.add_block('scale', style='box-style', @@ -235,7 +235,7 @@ complete')) colors=["#FF6060", "#A06060"], help_string=_('Palette of sensor blocks')) - PLUGIN_DICTIONARY['kbinput'] = self._prim_kbinput + primitive_dictionary['kbinput'] = self._prim_kbinput palette.add_block('kbinput', style='basic-style-extended-vertical', label=_('query keyboard'), @@ -243,7 +243,7 @@ complete')) help_string=_('query for keyboard input (results \ stored in keyboard block)')) self.tw.lc.def_prim('kbinput', 0, - lambda self: PLUGIN_DICTIONARY['kbinput']()) + lambda self: primitive_dictionary['kbinput']()) palette.add_block('keyboard', style='box-style', @@ -254,7 +254,7 @@ stored in keyboard block)')) block')) self.tw.lc.def_prim('keyboard', 0, lambda self: self.tw.lc.keyboard) - PLUGIN_DICTIONARY['readpixel'] = self._prim_readpixel + primitive_dictionary['readpixel'] = self._prim_readpixel palette.add_block('readpixel', style='basic-style-extended-vertical', label=_('read pixel'), @@ -262,9 +262,9 @@ block')) help_string=_('RGB color under the turtle is pushed \ to the stack')) self.tw.lc.def_prim('readpixel', 0, - lambda self: PLUGIN_DICTIONARY['readpixel']()) + lambda self: primitive_dictionary['readpixel']()) - PLUGIN_DICTIONARY['see'] = self._prim_see + primitive_dictionary['see'] = self._prim_see palette.add_block('see', style='box-style', label=_('turtle sees'), @@ -272,9 +272,9 @@ to the stack')) help_string=_('returns the color that the turtle \ "sees"')) self.tw.lc.def_prim('see', 0, - lambda self: PLUGIN_DICTIONARY['see']()) + lambda self: primitive_dictionary['see']()) - PLUGIN_DICTIONARY['time'] = self._prim_time + primitive_dictionary['time'] = self._prim_time palette.add_block('time', style='box-style', label=_('time'), @@ -283,7 +283,7 @@ to the stack')) help_string=_('elapsed time (in seconds) since \ program started')) self.tw.lc.def_prim('time', 0, - lambda self: PLUGIN_DICTIONARY['time']()) + lambda self: primitive_dictionary['time']()) def _extras_palette(self): @@ -291,7 +291,7 @@ program started')) colors=["#FF0000", "#A00000"], help_string=_('Palette of extra options')) - PLUGIN_DICTIONARY['push'] = self._prim_push + primitive_dictionary['push'] = self._prim_push palette.add_block('push', style='basic-style-1arg', label=_('push'), @@ -299,9 +299,9 @@ program started')) help_string=_('pushes value onto FILO (first-in \ last-out heap)')) self.tw.lc.def_prim('push', 1, - lambda self, x: PLUGIN_DICTIONARY['push'](x)) + lambda self, x: primitive_dictionary['push'](x)) - PLUGIN_DICTIONARY['printheap'] = self._prim_printheap + primitive_dictionary['printheap'] = self._prim_printheap palette.add_block('printheap', style='basic-style-extended-vertical', label=_('show heap'), @@ -309,18 +309,18 @@ last-out heap)')) help_string=_('shows values in FILO (first-in \ last-out heap)')) self.tw.lc.def_prim('printheap', 0, - lambda self: PLUGIN_DICTIONARY['printheap']()) + lambda self: primitive_dictionary['printheap']()) - PLUGIN_DICTIONARY['clearheap'] = self._prim_emptyheap + primitive_dictionary['clearheap'] = self._prim_emptyheap palette.add_block('clearheap', style='basic-style-extended-vertical', label=_('empty heap'), prim_name='clearheap', help_string=_('emptys FILO (first-in-last-out heap)')) self.tw.lc.def_prim('clearheap', 0, - lambda self: PLUGIN_DICTIONARY['clearheap']()) + lambda self: primitive_dictionary['clearheap']()) - PLUGIN_DICTIONARY['pop'] = self._prim_pop + primitive_dictionary['pop'] = self._prim_pop palette.add_block('pop', style='box-style', label=_('pop'), @@ -329,9 +329,9 @@ last-out heap)')) help_string=_('pops value off FILO (first-in \ last-out heap)')) self.tw.lc.def_prim('pop', 0, - lambda self: PLUGIN_DICTIONARY['pop']()) + lambda self: primitive_dictionary['pop']()) - PLUGIN_DICTIONARY['print'] = self._prim_print + primitive_dictionary['print'] = self._prim_print palette.add_block('comment', style='basic-style-1arg', label=_('comment'), @@ -339,7 +339,7 @@ last-out heap)')) default=_('comment'), help_string=_('places a comment in your code')) self.tw.lc.def_prim('comment', 1, - lambda self, x: PLUGIN_DICTIONARY['print'](x, True)) + lambda self, x: primitive_dictionary['print'](x, True)) palette.add_block('print', style='basic-style-1arg', @@ -348,9 +348,9 @@ last-out heap)')) help_string=_('prints value in status block at \ bottom of the screen')) self.tw.lc.def_prim('print', 1, - lambda self, x: PLUGIN_DICTIONARY['print'](x, False)) + lambda self, x: primitive_dictionary['print'](x, False)) - PLUGIN_DICTIONARY['myfunction'] = self._prim_myfunction + primitive_dictionary['myfunction'] = self._prim_myfunction palette.add_block('myfunc1arg', style='number-style-var-arg', label=[_('Python'), 'f(x)', 'x'], @@ -359,7 +359,7 @@ bottom of the screen')) help_string=_('a programmable block: used to add \ advanced single-variable math equations, e.g., sin(x)')) self.tw.lc.def_prim('myfunction', 2, - lambda self, f, x: PLUGIN_DICTIONARY['myfunction'](f, [x])) + lambda self, f, x: primitive_dictionary['myfunction'](f, [x])) palette.add_block('myfunc2arg', hidden=True, @@ -370,7 +370,7 @@ advanced single-variable math equations, e.g., sin(x)')) help_string=_('a programmable block: used to add \ advanced multi-variable math equations, e.g., sqrt(x*x+y*y)')) self.tw.lc.def_prim('myfunction2', 3, - lambda self, f, x, y: PLUGIN_DICTIONARY['myfunction'](f, [x, y])) + lambda self, f, x, y: primitive_dictionary['myfunction'](f, [x, y])) palette.add_block('myfunc3arg', hidden=True, @@ -381,10 +381,10 @@ advanced multi-variable math equations, e.g., sqrt(x*x+y*y)')) help_string=_('a programmable block: used to add \ advanced multi-variable math equations, e.g., sin(x+y+z)')) self.tw.lc.def_prim('myfunction3', 4, - lambda self, f, x, y, z: PLUGIN_DICTIONARY['myfunction']( + lambda self, f, x, y, z: primitive_dictionary['myfunction']( f, [x, y, z])) - PLUGIN_DICTIONARY['userdefined'] = self._prim_myblock + primitive_dictionary['userdefined'] = self._prim_myblock palette.add_block('userdefined', style='basic-style-var-arg', label=' ', @@ -394,7 +394,7 @@ advanced multi-variable math equations, e.g., sin(x+y+z)')) help_string=_('runs code found in the tamyblock.py \ module found in the Journal')) self.tw.lc.def_prim('userdefined', 1, - lambda self, x: PLUGIN_DICTIONARY['userdefined']([x])) + lambda self, x: primitive_dictionary['userdefined']([x])) palette.add_block('userdefined2args', hidden=True, @@ -406,7 +406,7 @@ module found in the Journal')) help_string=_('runs code found in the tamyblock.py \ module found in the Journal')) self.tw.lc.def_prim('userdefined2', 2, - lambda self, x, y: PLUGIN_DICTIONARY['userdefined']([x, y])) + lambda self, x, y: primitive_dictionary['userdefined']([x, y])) palette.add_block('userdefined3args', hidden=True, @@ -418,7 +418,7 @@ module found in the Journal')) help_string=_('runs code found in the tamyblock.py \ module found in the Journal')) self.tw.lc.def_prim('userdefined3', 3, - lambda self, x, y, z: PLUGIN_DICTIONARY['userdefined']([x, y, z])) + lambda self, x, y, z: primitive_dictionary['userdefined']([x, y, z])) palette.add_block('cartesian', style='basic-style-extended-vertical', @@ -445,7 +445,7 @@ module found in the Journal')) self.tw.lc.def_prim('turtle', 1, lambda self, x: self.tw.canvas.set_turtle(x)) - PLUGIN_DICTIONARY['skin'] = self._prim_reskin + primitive_dictionary['skin'] = self._prim_reskin palette.add_block('skin', hidden=True, style='basic-style-1arg', @@ -453,7 +453,7 @@ module found in the Journal')) prim_name='skin', help_string=_("put a custom 'shell' on the turtle")) self.tw.lc.def_prim('skin', 1, - lambda self, x: PLUGIN_DICTIONARY['skin'](x)) + lambda self, x: primitive_dictionary['skin'](x)) # macro palette.add_block('reskin', @@ -535,7 +535,7 @@ click to open')) self.tw.lc.def_prim('fullscreen', 0, lambda self: self.tw.set_fullscreen()) - PLUGIN_DICTIONARY['bulletlist'] = self._prim_list + primitive_dictionary['bulletlist'] = self._prim_list palette.add_block('list', hidden=True, style='bullet-style', @@ -544,7 +544,7 @@ click to open')) default=['∙ ', '∙ '], help_string=_('presentation bulleted list')) self.tw.lc.def_prim('bulletlist', 1, - PLUGIN_DICTIONARY['bulletlist'], True) + primitive_dictionary['bulletlist'], True) # macros palette.add_block('picturelist', @@ -670,7 +670,7 @@ Journal objects')) # deprecated blocks - PLUGIN_DICTIONARY['t1x1'] = self._prim_t1x1 + primitive_dictionary['t1x1'] = self._prim_t1x1 palette.add_block('template1x1', hidden=True, style='portfolio-style-1x1', @@ -681,9 +681,9 @@ Journal objects')) help_string=_('presentation template: select \ Journal object (with description)')) self.tw.lc.def_prim('t1x1', 2, - lambda self, a, b: PLUGIN_DICTIONARY['t1x1'](a, b)) + lambda self, a, b: primitive_dictionary['t1x1'](a, b)) - PLUGIN_DICTIONARY['t1x1a'] = self._prim_t1x1a + primitive_dictionary['t1x1a'] = self._prim_t1x1a palette.add_block('template1x1a', hidden=True, style='portfolio-style-1x1', @@ -694,9 +694,9 @@ Journal object (with description)')) help_string=_('presentation template: select \ Journal object (no description)')) self.tw.lc.def_prim('t1x1a', 2, - lambda self, a, b: PLUGIN_DICTIONARY['t1x1a'](a, b)) + lambda self, a, b: primitive_dictionary['t1x1a'](a, b)) - PLUGIN_DICTIONARY['2x1'] = self._prim_t2x1 + primitive_dictionary['2x1'] = self._prim_t2x1 palette.add_block('template2x1', hidden=True, style='portfolio-style-2x1', @@ -707,9 +707,9 @@ Journal object (no description)')) help_string=_("presentation template: select two \ Journal objects")) self.tw.lc.def_prim('t2x1', 3, - lambda self, a, b, c: PLUGIN_DICTIONARY['t2x1'](a, b, c)) + lambda self, a, b, c: primitive_dictionary['t2x1'](a, b, c)) - PLUGIN_DICTIONARY['1x2'] = self._prim_t1x2 + primitive_dictionary['1x2'] = self._prim_t1x2 palette.add_block('template1x2', hidden=True, style='portfolio-style-1x2', @@ -720,9 +720,9 @@ Journal objects")) help_string=_("presentation template: select two \ Journal objects")) self.tw.lc.def_prim('t1x2', 3, - lambda self, a, b, c: PLUGIN_DICTIONARY['t1x2'](a, b, c)) + lambda self, a, b, c: primitive_dictionary['t1x2'](a, b, c)) - PLUGIN_DICTIONARY['t2x2'] = self._prim_t2x2 + primitive_dictionary['t2x2'] = self._prim_t2x2 palette.add_block('template2x2', hidden=True, style='portfolio-style-2x2', @@ -733,7 +733,7 @@ Journal objects")) help_string=_("presentation template: select four \ Journal objects")) self.tw.lc.def_prim('t2x2', 5, - lambda self, a, b, c, d, e: PLUGIN_DICTIONARY['t2x2']( + lambda self, a, b, c, d, e: primitive_dictionary['t2x2']( a, b, c, d, e)) palette.add_block('templatelist', @@ -833,7 +833,7 @@ bullets')) return if type(n) == str or type(n) == unicode: if n[0:6] == 'media_' and \ - n[6:].lower not in MEDIA_BLOCKS_DICTIONARY: + n[6:].lower not in media_blocks_dictionary: try: if self.tw.running_sugar: try: @@ -941,9 +941,9 @@ bullets')) elif string[0:6] in ['media_', 'descr_', 'audio_', 'video_']: self.tw.lc.filepath = None self.tw.lc.dsobject = None - print string[6:], MEDIA_BLOCKS_DICTIONARY - if string[6:].lower() in MEDIA_BLOCKS_DICTIONARY: - MEDIA_BLOCKS_DICTIONARY[string[6:].lower()]() + print string[6:], media_blocks_dictionary + if string[6:].lower() in media_blocks_dictionary: + media_blocks_dictionary[string[6:].lower()]() elif os.path.exists(string[6:]): # is it a path? self.tw.lc.filepath = string[6:] elif self.tw.running_sugar: # is it a datastore object? -- cgit v0.9.1