summaryrefslogtreecommitdiff
path: root/test-cli/test/helpers/setup_xml.py
blob: 3fd9fd58733808cd9328998bab3e64a12daa5e54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import xml.etree.ElementTree as XMLParser

class XMLSetup (object):
    """aaaaa"""
    __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"""
        self.__tree = XMLParser.parse(filename)

    def __del__(self):
        """aaaaa"""
        pass

    def getdbConnectionStr (self):
        """aaaaa"""
        if self.__dbConnectionRaw is not None:
            return self.__dbConnectionRaw

        for element in self.__tree.iter('db'):
            self.__dbConnectionRaw = element.attrib
            self.__dbType = self.__dbConnectionRaw['type']
            if self.__dbType == "PgSQLConnection":
                self.__dbConnectionStr = self.getPostgresConnectionStr()
            return self.__dbConnectionStr

        return None

    def getPostgresConnectionStr (self):
        """aaaaa"""
        str = self.__dbConnectionRaw
        del str['type']
        return str

    def getMysqlConnectionStr (self):
        """aaaaa"""
        pass