def Auto def rootDirPath if sys platform win32 Windows if os environ g

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
def Auto():
def rootDirPath():
if sys.platform == 'win32': # Windows
if os.environ.get('SystemDrive'):
result = os.environ.get('SystemDrive')
else: # if cannot get
result = 'C:\\'
else: # UNIX & MacOS
result = '/'
return result
def homeDirPath():
if os.environ.get('HOME'):
result = os.environ.get('HOME')
else:
if sys.platform == 'win32': # Windows
if os.environ.get('USERPROFILE'):
result = os.environ.get('USERPROFILE')
elif os.environ.get('HOMEDRIVE') & os.environ.get('HOMEPATH'):
result = os.environ.get('HOMEDRIVE') + os.environ.get('HOMEPATH')
else:
result = rootDirPath
else: # UNIX & MacOS
result = rootDirPath()
return result
if os.environ.get('PSIDATADIR'):
profDir = os.environ.get('PSIDATADIR') + os.sep + 'profiles' + os.sep
else:
if sys.platform == 'win32': # Windows
if homeDirPath == rootDirPath(): # Windows 9x
profDir = '.'
else:
profDir = homeDirPath()
profDir += '\\PsiData\\profiles\\'
else: # UNIX & MacOS
profDir = homeDirPath() + '/.psi/profiles/'
if os.path.exists(profDir) & os.path.isdir(profDir):
names = os.listdir(profDir)
if len(names) > 0:
for name in names:
if os.path.isdir(profDir + name) & os.path.exists(profDir + name + os.sep + 'config.xml'):
print 'Profile: ' + name
ParseXML(profDir + name + os.sep + 'config.xml')
print
else:
print 'Profiles not found'
else:
print 'Psi IM data not found'