Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / src / nas,5.n2.os.2 / lib / python / lib / python2.4 / site-packages / Pmw / Pmw_1_2 / demos / DemoVersion.py
CommitLineData
86530b38
AT
1# Set the version of Pmw to use for the demonstrations based on the
2# directory name.
3
4import imp
5import os
6import string
7
8def expandLinks(path):
9 if not os.path.isabs(path):
10 path = os.path.join(os.getcwd(), path)
11 while 1:
12 if not os.path.islink(path):
13 break
14 dir = os.path.dirname(path)
15 path = os.path.join(dir, os.readlink(path))
16
17 return path
18
19def setPmwVersion():
20 file = imp.find_module(__name__)[1]
21 file = os.path.normpath(file)
22 file = expandLinks(file)
23
24 dir = os.path.dirname(file)
25 dir = expandLinks(dir)
26 dir = os.path.dirname(dir)
27 dir = expandLinks(dir)
28 dir = os.path.basename(dir)
29
30 version = string.replace(dir[4:], '_', '.')
31 import Pmw
32 if version in Pmw.installedversions():
33 Pmw.setversion(version)
34 else:
35 print 'No such Pmw version', `version` + '.',
36 print 'Using default version', `Pmw.version()`