def htmlview(self, sprites, event, fil): for sprite in sprites: fil.write(' <td>') visible = "" hidden = "" if event[sprite]['hidden']: for script in event[sprite]['hidden']: hidden += KelpPlugin.to_scratch_blocks(sprite, script) fil.write('<pre class="hidden"><p>{0}</p></pre>'.format(hidden)) if event[sprite]['visible']: for script in event[sprite]['visible']: visible += KelpPlugin.to_scratch_blocks(sprite, script) fil.write('<pre class="blocks"><p>{0}</p></pre>'.format(visible)) fil.write(' </td>') fil.write(' </tr>')
def broadcast_display(results): broadcast = results['broadcast'] thumbnails = results['thumbnails'] html = [] html.append('\n<h2 style="text-align:center;">Broadcast / Receive</h2>') message = "" for blocktype, lists in broadcast.items(): for (sprite, script) in lists: if KelpPlugin.script_start_type( script) == KelpPlugin.HAT_WHEN_I_RECEIVE: # check if the message is the same as the last one # if it is, print this script next to the last # otherwise, print it below the last if message != script[0].args[0].lower(): html.append('\n <tr>') message = script[0].args[0].lower() script_images = KelpPlugin.to_scratch_blocks(sprite, script) html.append('\n<td>') html.append('\n<p> {0}</p>'.format(sprite)) html.append( '\n <p><img src="{0}" height="100" width="100"></p>'. format(thumbnails[sprite])) html.append('\n<pre class="blocks">') html.append('\n<p>{0}</p>'.format(script_images)) html.append('\n</pre>') html.append('\n</td>') elif KelpPlugin.script_start_type != KelpPlugin.NO_HAT: html.append('\n</table>') html.append('\n<hr>') html.append('\n<h2>{0}</h2>'.format( KelpPlugin.SCRIPT_TITLES[blocktype])) html.append('\n<table>') if message == "": html.append('\n </tr>') html.append('\n <tr>') script_images = KelpPlugin.to_scratch_blocks(sprite, script) html.append('\n<td>') html.append('\n<p>{0}</p>'.format(sprite)) html.append( '\n <p><img src="{0}" height="100" width="100"></p>'. format(thumbnails[sprite])) html.append('\n<pre class="blocks">') html.append('\n<p>{0}</p>'.format(script_images)) html.append('\n</pre>') html.append('\n</td>') html.append('\n </tr>') html.append('\n</table>') return ''.join(html)
def event_display(results): thumbnails = results['thumbnails'] events = results['events'] html = [] sprites = [] html.append('<h2> Starting Scripts Table </h2>') html.append('<table>') # start the first row html.append('<tr>') # headings html.append('<th>Script Type</th>') for sprite in thumbnails.keys(): if sprite != 'screen': sprites.append(sprite) # sprite name html.append('<th>{0}</th>'.format(sprite)) # sprite thumbnail? # end the first row html.append('</tr>') # make a row for each event type for event_type, event in events.items(): html.append('<tr>') # new row html.append('<td>{0}</td>'.format(KelpPlugin.SCRIPT_TITLES[event_type])) # row header for sprite in sprites: html.append('<td><pre class="blocks"><p>') if event[sprite]['visible']: for script in event[sprite]['visible']: html.append(KelpPlugin.to_scratch_blocks(sprite, script)) html.append('</p></pre></td>') html.append('</tr>') # end row html.append('</table>') return ''.join(html)
def event_display(results): thumbnails = results['thumbnails'] events = results['events'] html = [] sprites = [] html.append('<h2> Starting Scripts Table </h2>') html.append('<table>') # start the first row html.append('<tr>') # headings html.append('<th>Script Type</th>') for sprite in thumbnails.keys(): if sprite != 'screen': sprites.append(sprite) # sprite name html.append('<th>{0}</th>'.format(sprite)) # sprite thumbnail? # end the first row html.append('</tr>') # make a row for each event type for event_type, event in events.items(): html.append('<tr>') # new row html.append('<td>{0}</td>'.format( SCRIPT_TITLES[event_type])) # row header for sprite in sprites: html.append('<td><pre class="blocks"><p>') if event[sprite]['visible']: for script in event[sprite]['visible']: html.append(KelpPlugin.to_scratch_blocks(sprite, script)) html.append('</p></pre></td>') html.append('</tr>') # end row html.append('</table>') return ''.join(html)
def InitScriptsDisplay(self, thumbnails, changes, file): sprite_names = [] for name in thumbnails.keys(): if name != 'screen': sprite_names.append(name) # Displays sprite names and pictures file.write('<h2> Uninitialized Scripts</h2>') file.write('<table border="1">') file.write(' <tr>') for sprite in sprite_names: file.write(' <th>{0}</th>'.format(sprite)) file.write(' </tr> <tr>') for sprite in sprite_names: file.write(' <td><img src="{0}" ></td>'.format( thumbnails[sprite])) file.write(' </tr>') # Displays uninitialized scripts file.write(' <tr>') for sprite in sprite_names: file.write(' <td>') for type, list in changes[sprite].items(): if list: for block, script in list: #This will display the problem block file.write( '<pre class="error"><p>{0}\n</p></pre>'.format( block.stringify(True))) #This will display the script that the block is in file.write( '<pre class="blocks"><p>{0}</p></pre>'.format( KelpPlugin.to_scratch_blocks(sprite, script))) file.write(' </td>') file.write(' </tr></table>') return 0
def htmlview(self, sprites, event, fil): for sprite in sprites: fil.write(' <td>') visible = "" hidden = "" if event[sprite]['hidden']: for script in event[sprite]['hidden']: hidden += KelpPlugin.to_scratch_blocks(sprite, script) fil.write( '<pre class="hidden"><p>{0}</p></pre>'.format(hidden)) if event[sprite]['visible']: for script in event[sprite]['visible']: visible += KelpPlugin.to_scratch_blocks(sprite, script) fil.write( '<pre class="blocks"><p>{0}</p></pre>'.format(visible)) fil.write(' </td>') fil.write(' </tr>')
def broadcastHTML(self, brod, thumbnails, file): message = "" for type, lists in brod.items(): for list in lists: file.write('<hr>') file.write('<h2>{0}<h2>'.format(type)) #heading file.write('<table border = "1">') for sprite, script in list: if self.script_start_type( script) == self.HAT_WHEN_I_RECEIVE: # check if the message is the same as the last one # if it is, print this script next to the last # otherwise, print it below the last if message != script[0].args[0].lower(): file.write(' </tr>') file.write(' <tr>') message = script[0].args[0].lower() script_images = KelpPlugin.to_scratch_blocks( sprite, script) file.write('<td>') file.write('<p> {0}</p>'.format(sprite)) file.write( ' <p><img src="{0}" height="100" width="100"></p>' .format(thumbnails[sprite])) file.write('<pre class="blocks">') file.write('<p>{0}</p>'.format(script_images)) file.write('</pre>') file.write('</td>') elif self.script_start_type != self.NO_HAT: if message == "": file.write(' </tr>') file.write(' <tr>') script_images = KelpPlugin.to_scratch_blocks( sprite, script) file.write('<p>{0}</p>'.format(sprite)) file.write( ' <p><img src="{0}" height="100" width="100"></p>' .format(thumbnails[sprite])) file.write('<pre class="blocks">') file.write('<p>{0}</p>'.format(script_images)) file.write('</pre>') file.write(' </tr>') file.write('</table>')
def broadcast_display(results): broadcast = results['broadcast'] thumbnails = results['thumbnails'] html = [] html.append('\n<h2 style="text-align:center;">Broadcast / Receive</h2>') message = "" for blocktype, lists in broadcast.items(): for (sprite, script) in lists: if KelpPlugin.script_start_type(script) == KelpPlugin.HAT_WHEN_I_RECEIVE: # check if the message is the same as the last one # if it is, print this script next to the last # otherwise, print it below the last if message != script[0].args[0].lower(): html.append('\n <tr>') message = script[0].args[0].lower() script_images = KelpPlugin.to_scratch_blocks(sprite, script) html.append('\n<td>') html.append('\n<p> {0}</p>'.format(sprite)) html.append('\n <p><img src="{0}" height="100" width="100"></p>'.format(thumbnails[sprite])) html.append('\n<pre class="blocks">') html.append('\n<p>{0}</p>'.format(script_images)) html.append('\n</pre>') html.append('\n</td>') elif KelpPlugin.script_start_type != KelpPlugin.NO_HAT: html.append('\n</table>') html.append('\n<hr>') html.append('\n<h2>{0}</h2>'.format(KelpPlugin.SCRIPT_TITLES[blocktype])) html.append('\n<table>') if message == "": html.append('\n </tr>') html.append('\n <tr>') script_images = KelpPlugin.to_scratch_blocks(sprite, script) html.append('\n<td>') html.append('\n<p>{0}</p>'.format(sprite)) html.append('\n <p><img src="{0}" height="100" width="100"></p>'.format(thumbnails[sprite])) html.append('\n<pre class="blocks">') html.append('\n<p>{0}</p>'.format(script_images)) html.append('\n</pre>') html.append('\n</td>') html.append('\n </tr>') html.append('\n</table>') return ''.join(html)
def initialization_display(results): changes = results['changes'] thumbnails = results['thumbnails'] html = [] empty = True for sprite in changes.keys(): for attr in changes[sprite].keys(): if changes[sprite][attr]: empty = False break if empty: return ''.join(html) sprite_names = [] for name in thumbnails.keys(): if name != 'screen': sprite_names.append(name) # Displays sprite names and pictures html.append('<h2> Uninitialized Scripts</h2>') html.append('<table border="20">') html.append(' <tr>') for sprite in sprite_names: html.append(' <th>{0}</th>'.format(sprite)) html.append(' </tr> <tr>') for sprite in sprite_names: html.append(' <td><img src="{0}" height="100" width="100"></td>'.format(thumbnails[sprite])) html.append(' </tr>') # Displays uninitialized scripts html.append(' <tr>') for sprite in sprite_names: html.append(' <td>') for type, list in changes[sprite].items(): if list: for block, script in list: #This will display the problem block html.append('<pre class="error"><p>{0}\n</p></pre>'.format(block.stringify(True))) #This will display the script that the block is in html.append('<pre class="blocks"><p>{0}</p></pre>'.format(KelpPlugin.to_scratch_blocks(sprite, script))) html.append(' </td>') html.append(' </tr></table>') return ''.join(html)
def initialization_display(results): changes = results['changes'] thumbnails = results['thumbnails'] html = [] empty = True for sprite in changes.keys(): for attr in changes[sprite].keys(): if changes[sprite][attr]: empty = False break if empty: return ''.join(html) sprite_names = [] for name in thumbnails.keys(): if name != 'screen': sprite_names.append(name) # Displays sprite names and pictures html.append('<h2> Uninitialized Scripts</h2>') html.append('<table border="20">') html.append(' <tr>') for sprite in sprite_names: html.append(' <th>{0}</th>'.format(sprite)) html.append(' </tr> <tr>') for sprite in sprite_names: html.append(' <td><img src="{0}" height="100" width="100"></td>'.format(thumbnails[sprite])) html.append(' </tr>') # Displays uninitialized scripts html.append(' <tr>') for sprite in sprite_names: html.append(' <td>') for type, list in changes[sprite].items(): if list: for block, script in list: #This will display the problem block html.append('<pre class="error"><p>{0}\n</p></pre>'.format(block.stringify(True))) #This will display the script that the block is in html.append('<pre class="blocks"><p>{0}</p></pre>'.format(KelpPlugin.to_scratch_blocks(sprite, script))) html.append(' </td>') html.append(' </tr></table>') return ''.join(html)