1 # -*- coding: UTF-8 -*-
2 # vim: expandtab sw=4 ts=4 sts=4:
5 OS dependant helper functions.
7 __author__
= 'Michal Čihař'
8 __email__
= 'michal@cihar.com'
10 Copyright © 2003 - 2010 Michal Čihař
12 This program is free software; you can redistribute it and/or modify it
13 under the terms of the GNU General Public License version 2 as published by
14 the Free Software Foundation.
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 if sys
.platform
== 'win32':
29 from win32com
.shell
import shellcon
, shell
33 def GetUserFullName():
35 Detects full user name from system information.
37 if sys
.platform
== 'win32':
39 return win32api
.GetUserNameEx(win32api
.NameDisplay
)
40 except pywintypes
.error
:
45 name
= pwd
.getpwuid(os
.getuid())[4]
47 name
= name
[:name
.index(',')]
52 Expands user path. This is replaced on Windows, because python
53 implementation has problems with encodings.
55 if sys
.platform
== 'win32':
56 if orig
.startswith('~'):
57 userhome
= shell
.SHGetFolderPath(0, shellcon
.CSIDL_APPDATA
, 0, 0)
58 return orig
.replace('~', userhome
, 1)
61 return os
.path
.expanduser(orig
)