svgui/pyjs/lib/sys.py
changeset 3359 2c924cf26161
parent 3358 7478d0c0dc1c
child 3360 746e3e3f6537
equal deleted inserted replaced
3358:7478d0c0dc1c 3359:2c924cf26161
     1 # the platform name (PyV8, smjs, Mozilla, IE6, Opera, Safari etc.)
       
     2 platform = ''  # to be updated by app, on compile
       
     3 
       
     4 # a dictionary of module override names (platform-specific)
       
     5 overrides = {}  # to be updated by app, on compile
       
     6 
       
     7 # the remote path for loading modules
       
     8 loadpath = None
       
     9 
       
    10 stacktrace = None
       
    11 
       
    12 appname = None
       
    13 
       
    14 
       
    15 def setloadpath(lp):
       
    16     global loadpath
       
    17     loadpath = lp
       
    18 
       
    19 
       
    20 def setappname(an):
       
    21     global appname
       
    22     appname = an
       
    23 
       
    24 
       
    25 def getloadpath():
       
    26     return loadpath
       
    27 
       
    28 
       
    29 def addoverride(module_name, path):
       
    30     overrides[module_name] = path
       
    31 
       
    32 
       
    33 def addstack(linedebug):
       
    34     JS("""
       
    35         if (pyjslib.bool((sys.stacktrace === null))) {
       
    36             sys.stacktrace = new pyjslib.List([]);
       
    37         }
       
    38         sys.stacktrace.append(linedebug);
       
    39     """)
       
    40 
       
    41 
       
    42 def popstack():
       
    43     JS("""
       
    44         sys.stacktrace.pop()
       
    45     """)
       
    46 
       
    47 
       
    48 def printstack():
       
    49     JS("""
       
    50         var res = '';
       
    51 
       
    52         var __l = sys.stacktrace.__iter__();
       
    53         try {
       
    54             while (true) {
       
    55                 var l = __l.next();
       
    56                 res +=  ( l + '\\n' ) ;
       
    57             }
       
    58         } catch (e) {
       
    59             if (e != pyjslib.StopIteration) {
       
    60                 throw e;
       
    61             }
       
    62         }
       
    63 
       
    64         return res;
       
    65     """)