diff options
author | Manel Caro <mcaro@iseebcn.com> | 2019-03-29 14:54:24 +0100 |
---|---|---|
committer | Manel Caro <mcaro@iseebcn.com> | 2019-03-29 14:54:24 +0100 |
commit | 77355baca0f628f5e95cbf1d8bf3c2475a95150f (patch) | |
tree | ed31cbe8ddc54b09ec471db0e033b33a9073748b /test-cli/test/helpers/setup_xml.py | |
parent | b44174ae3decc9f9498541ce9aeed84ce183a9eb (diff) | |
download | board-77355baca0f628f5e95cbf1d8bf3c2475a95150f.zip board-77355baca0f628f5e95cbf1d8bf3c2475a95150f.tar.gz board-77355baca0f628f5e95cbf1d8bf3c2475a95150f.tar.bz2 |
Modify database connection object and xml parser object
Diffstat (limited to 'test-cli/test/helpers/setup_xml.py')
-rw-r--r-- | test-cli/test/helpers/setup_xml.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/test-cli/test/helpers/setup_xml.py b/test-cli/test/helpers/setup_xml.py index 3fd9fd5..c1dc21e 100644 --- a/test-cli/test/helpers/setup_xml.py +++ b/test-cli/test/helpers/setup_xml.py @@ -1,22 +1,23 @@ import xml.etree.ElementTree as XMLParser + class XMLSetup (object): - """aaaaa""" + """XML Setup Parser""" __tree = None # Parser __dbType = None # database connection required: PgSQLConnection __dbConnectionRaw = None # Connection string in raw __dbConnectionStr = None # Connection string to use in sql object connection def __init__(self, filename): - """aaaaa""" + """Parse the file in the constructor""" self.__tree = XMLParser.parse(filename) def __del__(self): - """aaaaa""" + """Destructor do nothing""" pass - def getdbConnectionStr (self): - """aaaaa""" + def getdbConnectionStr(self): + """XML to database connection string""" if self.__dbConnectionRaw is not None: return self.__dbConnectionRaw @@ -29,7 +30,7 @@ class XMLSetup (object): return None - def getPostgresConnectionStr (self): + def getPostgresConnectionStr(self): """aaaaa""" str = self.__dbConnectionRaw del str['type'] @@ -37,4 +38,11 @@ class XMLSetup (object): def getMysqlConnectionStr (self): """aaaaa""" - pass
\ No newline at end of file + pass + + def getBoard(self, key, default): + for element in self.__tree.iter('board'): + if key in element.attrib: + return element.attrib[key] + return default + |