#Pyjsdl - Python-to-JavaScript Multimedia Framework
#Copyright (c) 2013 James Garnon
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in
#all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
#THE SOFTWARE.
#
#Pyjsdl version 0.24
#Project Site: https://gatc.ca/

from pyjsdl import env
from pyjsdl import util
from pyjsdl.display import Display
from pyjsdl.surface import Surface
from pyjsdl.rect import Rect
from pyjsdl.image import Image
from pyjsdl.event import Event
from pyjsdl.key import Key
from pyjsdl.mouse import Mouse
from pyjsdl.color import Color
from pyjsdl.mixer import Mixer
from pyjsdl.time import Time
from pyjsdl import draw
from pyjsdl import transform
from pyjsdl import surfarray
from pyjsdl import mask
from pyjsdl import font
from pyjsdl import sprite
from pyjsdl import cursors
from pyjsdl.locals import *

event = Event()
env.set_env('event', event)
time = Time()
display = Display()
image = Image()
mixer = Mixer()
mouse = Mouse()
key = Key()

init = lambda:None

def setup(callback, images=None):
    """
    Initialize module for script execution.
    Argument include callback function to run and optional images list to preload.
    Callback function can also be an object with a run method to call.
    The images can be image URL, or file-like object or base64 data in format (name.ext,data).
    """
    display.setup(callback, images)

def set_callback(callback):
    """
    Set callback function.
    Argument callback function to run.
    Callback function can also be an object with a run method to call.
    """
    display.set_callback(callback)

def setup_images(images):
    """
    Add images to image preload list.
    The argument is an image or list of images representing an image URL, or file-like object or base64 data in format (name.ext,data).
    Image preloading occurs at setup call.
    """
    display.set_images(images)

def quit():
    """
    Terminates canvas repaint and callback function.
    """
    canvas = display.get_canvas()
    canvas.stop()
    mixer.quit()
    time._stop_timers()

class error(RuntimeError):
    pass


@@ -1745,16 +1745,240 @@
 port *%0A%0A
+%0A_initialized = False%0A%0Adef init():%0A    %22%22%22%0A    Initialize module.%0A    %22%22%22%0A    global time, display, image, event, key, mouse, mixer, _initialized%0A    if _initialized:%0A        return%0A    else:%0A        _initialized = True%0A    
 event = 
@@ -1985,16 +1985,20 @@
 Event()%0A
+    
 env.set_
@@ -2017,16 +2017,20 @@
  event)%0A
+    
 time = T
@@ -2035,16 +2035,20 @@
  Time()%0A
+    
 display 
@@ -2059,16 +2059,20 @@
 splay()%0A
+    
 image = 
@@ -2079,16 +2079,20 @@
 Image()%0A
+    
 mixer = 
@@ -2099,16 +2099,20 @@
 Mixer()%0A
+    
 mouse = 
@@ -2119,16 +2119,20 @@
 Mouse()%0A
+    
 key = Ke
@@ -2144,22 +2144,11 @@
 init
- = lambda:None
+()%0A
 %0A%0Ade
@@ -2521,24 +2521,25 @@
 k, images)%0A%0A
+%0A
 def set_call
@@ -2743,16 +2743,17 @@
 lback)%0A%0A
+%0A
 def setu
@@ -3035,16 +3035,17 @@
 mages)%0A%0A
+%0A
 def quit
@@ -3211,16 +3211,17 @@
 mers()%0A%0A
+%0A
 class er

refactor module init