| 1 |
#!/usr/bin/env python |
|---|
| 2 |
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 3 |
##~ License |
|---|
| 4 |
##~ |
|---|
| 5 |
##- The RuneBlade Foundation library is intended to ease some |
|---|
| 6 |
##- aspects of writing intricate Jabber, XML, and User Interface (wxPython, etc.) |
|---|
| 7 |
##- applications, while providing the flexibility to modularly change the |
|---|
| 8 |
##- architecture. Enjoy. |
|---|
| 9 |
##~ |
|---|
| 10 |
##~ Copyright (C) 2002 TechGame Networks, LLC. |
|---|
| 11 |
##~ |
|---|
| 12 |
##~ This library is free software; you can redistribute it and/or |
|---|
| 13 |
##~ modify it under the terms of the BSD style License as found in the |
|---|
| 14 |
##~ LICENSE file included with this distribution. |
|---|
| 15 |
##~ |
|---|
| 16 |
##~ TechGame Networks, LLC can be reached at: |
|---|
| 17 |
##~ 3578 E. Hartsel Drive #211 |
|---|
| 18 |
##~ Colorado Springs, Colorado, USA, 80920 |
|---|
| 19 |
##~ |
|---|
| 20 |
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 21 |
|
|---|
| 22 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 23 |
#~ Imports |
|---|
| 24 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 25 |
|
|---|
| 26 |
import sys |
|---|
| 27 |
import getopt |
|---|
| 28 |
import hotshot, hotshot.stats |
|---|
| 29 |
|
|---|
| 30 |
from RBRapier.Formats.SVG.SVGSkinner import SkinFile |
|---|
| 31 |
from RBRapier.Formats.SVG import RapierRenderItems |
|---|
| 32 |
|
|---|
| 33 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 34 |
#~ Main |
|---|
| 35 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 36 |
|
|---|
| 37 |
def main(svgfiles): |
|---|
| 38 |
for svgfile in svgfiles: |
|---|
| 39 |
skin = SkinFile(svgfile, SVGRenderItemFactory=RapierRenderItems.RapierSVGRenderItemFactory()) |
|---|
| 40 |
renderable = skin.object.Compile() |
|---|
| 41 |
del skin |
|---|
| 42 |
del renderable |
|---|
| 43 |
|
|---|
| 44 |
if __name__ == '__main__': |
|---|
| 45 |
options, svgfiles = getopt.getopt(sys.argv[1:], 'psf:c:', ['sort=']) |
|---|
| 46 |
statcount = None |
|---|
| 47 |
statfile = 'svgdisplay.profile' |
|---|
| 48 |
sortcolumns = ('time', 'calls') |
|---|
| 49 |
runprofile = False |
|---|
| 50 |
loadstats = False |
|---|
| 51 |
printstats = False |
|---|
| 52 |
|
|---|
| 53 |
for opt, arg in options: |
|---|
| 54 |
if opt in ('-c',): |
|---|
| 55 |
statcount = int(arg) |
|---|
| 56 |
elif opt in ('-f',): |
|---|
| 57 |
statfile = arg |
|---|
| 58 |
elif opt in ('-p',): |
|---|
| 59 |
runprofile = True |
|---|
| 60 |
elif opt in ('-l',): |
|---|
| 61 |
loadstats = True |
|---|
| 62 |
printstats = False |
|---|
| 63 |
elif opt in ('-s',): |
|---|
| 64 |
loadstats = True |
|---|
| 65 |
printstats = True |
|---|
| 66 |
elif opt in ('--sort',): |
|---|
| 67 |
sortcolumns = arg.split(',') |
|---|
| 68 |
else: |
|---|
| 69 |
raise ValueError, "Unknow option %r" % (opt,) |
|---|
| 70 |
|
|---|
| 71 |
if runprofile: |
|---|
| 72 |
prof = hotshot.Profile(statfile) |
|---|
| 73 |
prof.runcall(main, svgfiles) |
|---|
| 74 |
prof.close() |
|---|
| 75 |
|
|---|
| 76 |
if loadstats: |
|---|
| 77 |
stats = hotshot.stats.load(statfile) |
|---|
| 78 |
|
|---|
| 79 |
if printstats: |
|---|
| 80 |
stats.sort_stats(*sortcolumns) |
|---|
| 81 |
if statcount is not None: |
|---|
| 82 |
stats.print_stats(statcount) |
|---|
| 83 |
else: stats.print_stats() |
|---|
| 84 |
|
|---|