Created
November 13, 2016 15:22
-
-
Save DEKHTIARJonathan/38377375636f593ace63ec3d29d9ea90 to your computer and use it in GitHub Desktop.
Rapid API Prototyping with Bottle.py - loadConf.py
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
| ################ Import Libraries ################ | |
| import os.path | |
| import xml.etree.ElementTree as XML | |
| def loadAPIConf(confPath = 'conf.xml'): | |
| configurations = XML.parse(confPath).getroot() | |
| servers = dict() | |
| for serv in configurations.iter('APIserver'): | |
| serverName = serv.attrib['serverName'] | |
| serverPort = serv.attrib['port'] | |
| serverIP = serv.attrib['ip'] | |
| serverLocal = serv.attrib['local'] | |
| servers[serverName] = { | |
| 'ip':serverIP, | |
| 'port':serverPort, | |
| 'local':str2bool(serverLocal) | |
| } | |
| return servers | |
| def str2bool(v): | |
| return v.lower() == "true" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment