summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Rouse <jr@its.to>2020-06-02 00:20:20 -0700
committerGitHub <noreply@github.com>2020-06-02 00:20:20 -0700
commit23aecfc5a2de4475146318e7608330fff42ef2a5 (patch)
tree47f47281da7fafdb63197c5e54f4f8845ab0c38f
parentc94974d3a40cbaa6aca6931ca224c8cb2b0ea9c5 (diff)
parent4534511708f20fdd9f51315e3885585b70c10bbf (diff)
downloadappdirs-23aecfc5a2de4475146318e7608330fff42ef2a5.tar.gz
Merge pull request #133 from ofek/patch-1
Remove unnecessary use of pywin32 for loading Windows folder
-rw-r--r--appdirs.py43
1 files changed, 7 insertions, 36 deletions
diff --git a/appdirs.py b/appdirs.py
index bd5357e..fcc26ad 100644
--- a/appdirs.py
+++ b/appdirs.py
@@ -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