Created
June 6, 2013 22:59
-
-
Save elebertus/5725696 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#eureka_connect.conf | |
{ | |
"eureka_connect": { | |
"url": "http://33.33.33.20:8080/eureka/v2/apps/EUREKA-VAGRANT-001", | |
"get_header": "'Accept': 'application/json'", | |
"post_header": "'Content-Type': 'application/json'", | |
"timeout": 3 | |
} | |
} | |
# rasher_config.py | |
import json | |
class RasherConfigParse(object): | |
def __init__(self, conf_file): | |
self.conf = json.load(open(conf_file)) | |
def get_key(self, *key): | |
key_list = [] | |
count = 0 | |
while(count < len(key)): | |
new_key = "['%s']" % key[count] | |
key_list.append(new_key) | |
count = count + 1 | |
target_value = "self.conf" + ''.join(key_list) | |
return eval(target_value) | |
#sample_use.py | |
#!/usr/bin/python | |
from rasher_config import RasherConfigParse | |
test = RasherConfigParse('eureka_connect.conf') | |
print test.get_key('eureka_connect', 'post_header') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment