render_test.py :  » Web-Server » SkunkWEB » skunkweb-3.4.4 » pylibs » DT » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Web Server » SkunkWEB 
SkunkWEB » skunkweb 3.4.4 » pylibs » DT » render_test.py
#  
#  Copyright (C) 2001 Andrew T. Csillag <drew_csillag@geocities.com>
#  
#      You may distribute under the terms of either the GNU General
#      Public License or the SkunkWeb License, as specified in the
#      README file.
#   
from DT import *

import sys

class nsc:
    this='that'
    num=1

def renderException():
    """take an exception and return a traceback string"""
    import traceback
    TraceBack=traceback
    import StringIO
    import DTParser
    import DTLexer
    import DTTags
    import string
    import types
    out=StringIO.StringIO()

    out.write('Traceback (innermost last):\n')
    TraceBack.print_tb(sys.exc_traceback, file=out)
    if (type(sys.exc_value) == types.InstanceType
        and sys.exc_value.__class__ == DTLexer.DTToken):
        
        out.write('%s\n' % sys.exc_value.lineno())
        out.write('%s: %s\n' % (sys.exc_type, sys.exc_value))
    elif (type(sys.exc_value) == types.InstanceType
        and issubclass(sys.exc_value.__class__, DTParser.ParserException)):
        out.write('%s\n' % sys.exc_value.data.lineno())
        out.write('%s: %s\n' % (sys.exc_type, sys.exc_value))
    elif sys.exc_type == DTTags.RaiseException:
        out.write('%s\n' % sys.exc_value[0].lineno())
        out.write('\nraise arguments:\n---------------\n')
        for i in sys.exc_value[1]:
            out.write('%s=%s\n' % (i[0], repr(i[1])))
        out.write('\nRaising tag:\n%s\n' % str(sys.exc_value[0].tag))
    else:
        if DTParser.CurrentTag is not None:
            out.write('Probable location: %s\n' %
                      DTParser.CurrentTag.lineno())
            out.write('Probable Offending Tag: %s\n' %
                      str(DTParser.CurrentTag))
        else:
            out.write('no tag available\n')
        out.write('%s: %s\n' % (sys.exc_type, sys.exc_value))
    return out.getvalue()

if __name__=='__main__':
    import time
    text=open(sys.argv[1]).read()
    if 1:#try:
        b=time.time()
        a=time.time()
        dt=DTCompiled(text, sys.argv[1])
        print 'loadtime = ', time.time()-a
        ns=nsc()
        a=time.time()
        text=dt(ns)
        print text
        print 'rendertime = ', time.time()-a
        print 'totaltime = ', time.time()-b
    #except:
    #    print renderException()
        
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.