From d1828cf05ac6243c12036f7fa0132992b86d8c83 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Tue, 25 Feb 2020 17:27:20 -0500 Subject: Remove unnecessary use of pywin32 for loading Windows folder --- appdirs.py | 41 +++++------------------------------------ 1 file changed, 5 insertions(+), 36 deletions(-) diff --git a/appdirs.py b/appdirs.py index 975e9bf..4cd0083 100644 --- a/appdirs.py +++ b/appdirs.py @@ -484,33 +484,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 - # . - 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 @@ -565,18 +538,14 @@ 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 + _get_win_folder = _get_win_folder_with_ctypes except ImportError: try: - from ctypes import windll - _get_win_folder = _get_win_folder_with_ctypes + import com.sun.jna + _get_win_folder = _get_win_folder_with_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 #---- self test code -- cgit v1.2.1