Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def parse_info(response):
- "Parse the result of Redis's INFO command into a Python dict"
- info = {}
- def get_value(value):
- if ',' not in value:
- return value
- sub_dict = {}
- for item in value.split(',',2):
- k, v = item.split('=')
- try:
- sub_dict[k] = int(v)
- except ValueError:
- sub_dict[k] = v
- return sub_dict
- for line in response.splitlines():
- key, value = line.split(':')
- try:
- info[key] = int(value)
- except ValueError:
- info[key] = get_value(value)
- return info
Add Comment
Please, Sign In to add comment