[Checkins] SVN: Sandbox/J1m/customdoctests/src/zc/customdoctests/js.py Provide load and print, like rhino and the spider monkey command line

Jim Fulton jim at zope.com
Fri Feb 4 14:25:25 EST 2011


Log message for revision 120103:
  Provide load and print, like rhino and the spider monkey command line
  do.
  
  Don't provide console. (env.js provides that.)
  

Changed:
  U   Sandbox/J1m/customdoctests/src/zc/customdoctests/js.py

-=-
Modified: Sandbox/J1m/customdoctests/src/zc/customdoctests/js.py
===================================================================
--- Sandbox/J1m/customdoctests/src/zc/customdoctests/js.py	2011-02-04 16:45:31 UTC (rev 120102)
+++ Sandbox/J1m/customdoctests/src/zc/customdoctests/js.py	2011-02-04 19:25:24 UTC (rev 120103)
@@ -46,20 +46,8 @@
     globs['JS'] = JS = cx.execute
     globs['add_js_global'] = cx.add_global
 
-
-    # Emulate rhino load:
-    def load(name):
-        JS(open(name).read(), name)
-
-    cx.add_global('load', load)         # rhino compat
-    cx.add_global(
-        'print',
-        lambda *s:
-        sys.stdout.write('%s\n' % ' '.join(map(str, s)))
-        ) # rhino compatish
-
-    cx.add_global('console', dict(
-        error = lambda s: sys.stdout.write('Error: %s\n' % (s, )),
-        info = lambda s: sys.stdout.write('Info: %s\n' % (s, )),
-        log = lambda s: sys.stdout.write('%s\n' % (s, )),
-        ))
+    # Rhino & spidermonkey/js compatability functions
+    cx.add_global('load', lambda name: JS(open(name).read(), name))
+    cx.add_global('print',
+                  lambda *s: sys.stdout.write('%s\n' % ' '.join(map(str, s)))
+                  )



More information about the checkins mailing list