Remove redundant checking for hasattr(self, 'activated_env') since activated_environment() function already does that. Also change activated_environment() to return a pre-split list instead of a string that caller is expected to split.

This commit is contained in:
Jukka Jylänki
2018-07-20 10:02:55 +03:00
parent df9957f0dc
commit 23dba8d27b

14
emsdk
View File

@@ -1171,9 +1171,9 @@ class Tool:
def activated_environment(self):
if hasattr(self, 'activated_env'):
return self.expand_vars(self.activated_env)
return self.expand_vars(self.activated_env).split(';')
else:
return ''
return []
def compatible_with_this_os(self):
if hasattr(self, 'os'):
@@ -1269,8 +1269,7 @@ class Tool:
# Returns true if the system environment variables requires by this tool are currently active.
def is_env_active(self):
if hasattr(self, 'activated_env'):
envs = self.activated_environment().split(';')
envs = self.activated_environment()
for env in envs:
(key, value) = parse_key_value(env)
if not key in os.environ or to_unix_path(os.environ[key]) != to_unix_path(value):
@@ -1288,8 +1287,8 @@ class Tool:
return True
def win_activate_env_vars(self, permanently_activate):
if WINDOWS and hasattr(self, 'activated_env'):
envs = self.activated_environment().split(';')
if WINDOWS:
envs = self.activated_environment()
for env in envs:
(key, value) = parse_key_value(env)
@@ -1956,8 +1955,7 @@ def construct_env(tools_to_activate, permanent):
mkdir_p(em_cache_dir)
for tool in tools_to_activate:
if hasattr(tool, 'activated_env'):
envs = tool.activated_environment().split(';')
envs = tool.activated_environment()
for env in envs:
(key, value) = parse_key_value(env)
value = to_native_path(tool.expand_vars(value))