@staticmethod<EOL><INDENT>def mergeDictionaries(sourceDictionary, destinationDictionary):<DEDENT>
log = Logger()<EOL>varNamePattern = re.compile(r"<STR_LIT>")<EOL>varTypePattern = re.compile(r"<STR_LIT>")<EOL>for key, value in sourceDictionary.items():<EOL><INDENT>if key == "<STR_LIT>":<EOL><INDENT>continue<EOL><DEDENT>if isinstance(value, dict):<EOL><INDENT>node = destinationDictionary.setdefault(key, {})<EOL>Config.mergeDictionaries(value, node)<EOL><DEDENT>elif isinstance(value, str) and (value.startswith("<STR_LIT>") or value.startswith("<STR_LIT>")):<EOL><INDENT>nameMatch = varNamePattern.match(value)<EOL>if nameMatch is None:<EOL><INDENT>log.warn("<STR_LIT>", name=value)<EOL>continue<EOL><DEDENT>envVariableName = nameMatch.group("<STR_LIT:name>")<EOL>if envVariableName not in os.environ:<EOL><INDENT>log.warn("<STR_LIT>", name=envVariableName)<EOL>continue<EOL><DEDENT>if value.startswith("<STR_LIT>"): <EOL><INDENT>typeMatch = varTypePattern.match(value)<EOL>if typeMatch is not None:<EOL><INDENT>envVariableType = typeMatch.group("<STR_LIT:type>")<EOL>if envVariableType == "<STR_LIT>":<EOL><INDENT>destinationDictionary[key] = str(os.environ[envVariableName])<EOL><DEDENT>elif envVariableType == "<STR_LIT>":<EOL><INDENT>if os.environ[envVariableName] == "<STR_LIT:1>":<EOL><INDENT>destinationDictionary[key] = True<EOL><DEDENT>elif os.environ[envVariableName] == "<STR_LIT:0>":<EOL><INDENT>destinationDictionary[key] = False<EOL><DEDENT><DEDENT>elif envVariableType == "<STR_LIT>":<EOL><INDENT>destinationDictionary[key] = int(os.environ[envVariableName])<EOL><DEDENT>elif envVariableType == "<STR_LIT>":<EOL><INDENT>destinationDictionary[key] = float(os.environ[envVariableName])<EOL><DEDENT>elif envVariableType == "<STR_LIT>":<EOL><INDENT>try:<EOL><INDENT>destinationDictionary[key] = json.loads(os.environ[envVariableName])<EOL><DEDENT>except Exception:<EOL><INDENT>log.warn(<EOL>"<STR_LIT>",<EOL>name=envVariableName<EOL>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>log.warn(<EOL>"<STR_LIT>",<EOL>name=envVariableName,<EOL>type=envVariableType<EOL>)<EOL>continue<EOL><DEDENT><DEDENT>else:<EOL><INDENT>destinationDictionary[key] = os.environ[envVariableName]<EOL><DEDENT><DEDENT>elif value.startswith("<STR_LIT>"): <EOL><INDENT>filePath = os.environ[envVariableName]<EOL>if not os.path.isfile(filePath):<EOL><INDENT>log.warn(<EOL>"<STR_LIT>",<EOL>filePath=filePath,<EOL>)<EOL>continue<EOL><DEDENT>if not os.access(filePath, os.R_OK):<EOL><INDENT>log.warn(<EOL>"<STR_LIT>",<EOL>filePath=filePath,<EOL>)<EOL>continue<EOL><DEDENT>filePointer = open(filePath, "<STR_LIT:r>")<EOL>destinationDictionary[key] = filePointer.read().strip()<EOL>filePointer.close()<EOL><DEDENT><DEDENT>elif isinstance(value, str) and value.startswith("<STR_LIT>"):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>destinationDictionary[key] = value<EOL><DEDENT><DEDENT>return destinationDictionary<EOL>
Deep merge dictionaries recursively.

:param sourceDictionary: <dict> first dictionary with data
:param destinationDictionary: <dict> second dictionary with data
:return: <dict> merged dictionary