Skip to content
This repository was archived by the owner on Apr 12, 2018. It is now read-only.

Commit 42c745e

Browse files
committed
Adding check to see if HOME env is even set
1 parent 7a378d7 commit 42c745e

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

swf/settings.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,21 @@ def from_env():
117117
return hsh
118118

119119

120+
def from_home(path='.swf'):
121+
"""Retrieves settings from home environment
122+
123+
If HOME environment is applicapable, search for any files in *path*.
124+
125+
:rtype: dict
126+
127+
"""
128+
if 'HOME' in os.environ:
129+
swf_path = os.path.join(os.environ['HOME'], path)
130+
return from_file(swf_path)
131+
132+
return {}
133+
134+
120135
def get(path='.swf'):
121136
"""Retrieves settings from a file or the environment.
122137
@@ -128,8 +143,8 @@ def get(path='.swf'):
128143
:rtype: dict
129144
130145
"""
131-
home_directory = os.environ['HOME']
132-
return from_file(os.path.join(home_directory, path)) or from_env()
146+
147+
return from_home(path) or from_env()
133148

134149

135150
def set(**settings):

0 commit comments

Comments
 (0)