Created
April 6, 2010 13:52
-
-
Save jmrodri/357615 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def read_user_config(): | |
config = {} | |
file_loc = os.path.expanduser("~/.spacewalk-build-rc") | |
try: | |
f = open(file_loc) | |
except: | |
file_loc = os.path.expanduser("~/.titorc") | |
try: | |
f = open(file_loc) | |
except: | |
# File doesn't exist but that's ok because it's optional. | |
return config | |
for line in f.readlines(): | |
if line.strip() == "": | |
continue | |
tokens = line.split("=") | |
if len(tokens) != 2: | |
raise Exception("Error parsing ~/.spacewalk-build-rc: %s" % line) | |
config[tokens[0]] = tokens[1].strip() | |
return config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment