Skip to content

Instantly share code, notes, and snippets.

@jmrodri
Created April 6, 2010 13:52
Show Gist options
  • Save jmrodri/357615 to your computer and use it in GitHub Desktop.
Save jmrodri/357615 to your computer and use it in GitHub Desktop.
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