summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOfek Lev <ofekmeister@gmail.com>2020-02-25 17:27:20 -0500
committerGitHub <noreply@github.com>2020-02-25 17:27:20 -0500
commitd1828cf05ac6243c12036f7fa0132992b86d8c83 (patch)
tree91304366a83b88e0a6cf788f3018177283c2f746
parent6d3a2188e0ae793a9f45de735a5cf515613dba27 (diff)
downloadappdirs-d1828cf05ac6243c12036f7fa0132992b86d8c83.tar.gz
Remove unnecessary use of pywin32 for loading Windows folder
-rw-r--r--appdirs.py41
1 files 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
- # <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
@@ -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