Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make envvars cpython compatible #1862

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 4 additions & 16 deletions pyrevitlib/pyrevit/coreutils/envvars.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,8 @@ def get_pyrevit_env_var(param_name):
# This function returns None if it can not find the parameter.
# Thus value of None should not be used for params

data_dict = AppDomain.CurrentDomain.GetData(ENV_VAR_DICT_NAME)

if data_dict:
try:
return data_dict[param_name]
except KeyError:
return None
else:
return None
data_dict = get_pyrevit_env_vars()
return data_dict.get(param_name) if data_dict else None


def set_pyrevit_env_var(param_name, param_value):
Expand All @@ -117,11 +110,6 @@ def set_pyrevit_env_var(param_name, param_value):
"""
# Get function returns None if it can not find the parameter.
# Thus value of None should not be used for params
data_dict = AppDomain.CurrentDomain.GetData(ENV_VAR_DICT_NAME)

if data_dict:
data_dict[param_name] = param_value
else:
data_dict = {param_name: param_value}

data_dict = get_pyrevit_env_vars() or {}
data_dict[param_name] = param_value
AppDomain.CurrentDomain.SetData(ENV_VAR_DICT_NAME, data_dict)