diff options
-rw-r--r-- | appdirs.py | 43 |
1 files changed, 7 insertions, 36 deletions
@@ -483,33 +483,6 @@ def _get_win_folder_from_registry(csidl_name): return dir -def _get_win_folder_with_pywin32(csidl_name): - from win32com.shell import shellcon, shell - dir = shell.SHGetFolderPath(0, getattr(shellcon, csidl_name), 0, 0) - # Try to make this a unicode path because SHGetFolderPath does - # not return unicode strings when there is unicode data in the - # path. - try: - dir = unicode(dir) - - # Downgrade to short path name if have highbit chars. See - # <http://bugs.activestate.com/show_bug.cgi?id=85099>. - has_high_char = False - for c in dir: - if ord(c) > 255: - has_high_char = True - break - if has_high_char: - try: - import win32api - dir = win32api.GetShortPathName(dir) - except ImportError: - pass - except UnicodeError: - pass - return dir - - def _get_win_folder_with_ctypes(csidl_name): import ctypes @@ -564,18 +537,16 @@ def _get_win_folder_with_jna(csidl_name): if system == "win32": try: - import win32com.shell - _get_win_folder = _get_win_folder_with_pywin32 + from ctypes import windll except ImportError: try: - from ctypes import windll - _get_win_folder = _get_win_folder_with_ctypes + import com.sun.jna except ImportError: - try: - import com.sun.jna - _get_win_folder = _get_win_folder_with_jna - except ImportError: - _get_win_folder = _get_win_folder_from_registry + _get_win_folder = _get_win_folder_from_registry + else: + _get_win_folder = _get_win_folder_with_jna + else: + _get_win_folder = _get_win_folder_with_ctypes #---- self test code |