summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin McClusky <kmcclusky@inductiveautomation.com>2020-08-29 14:47:36 -0700
committerKevin McClusky <kmcclusky@inductiveautomation.com>2020-08-29 14:47:36 -0700
commita9a4640abef12db76c693babfd1d98470407edad (patch)
tree05b5c9b2425472d7cd1f6f406dbed55088365bc8
parent699bc891844233847ca6c9cac7c8f8eede2a0eae (diff)
downloadappdirs-a9a4640abef12db76c693babfd1d98470407edad.tar.gz
Add os.environ fallback for jython
-rw-r--r--appdirs.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/appdirs.py b/appdirs.py
index fcc26ad..20103ba 100644
--- a/appdirs.py
+++ b/appdirs.py
@@ -535,6 +535,15 @@ def _get_win_folder_with_jna(csidl_name):
return dir
+def _get_win_folder_from_environ(csidl_name):
+ env_var_name = {
+ "CSIDL_APPDATA": "APPDATA",
+ "CSIDL_COMMON_APPDATA": "ALLUSERSPROFILE",
+ "CSIDL_LOCAL_APPDATA": "LOCALAPPDATA",
+ }[csidl_name]
+
+ return os.environ[env_var_name]
+
if system == "win32":
try:
from ctypes import windll
@@ -542,7 +551,15 @@ if system == "win32":
try:
import com.sun.jna
except ImportError:
- _get_win_folder = _get_win_folder_from_registry
+ try:
+ if PY3:
+ import winreg as _winreg
+ else:
+ import _winreg
+ except ImportError:
+ _get_win_folder = _get_win_folder_from_environ
+ else:
+ _get_win_folder = _get_win_folder_from_registry
else:
_get_win_folder = _get_win_folder_with_jna
else: