(log_format, logFile, rex)
| 8 | |
| 9 | |
| 10 | def dictionaryBuilder(log_format, logFile, rex): |
| 11 | doubleDictionaryList = {"dictionary^DHT": -1} |
| 12 | triDictionaryList = {"dictionary^DHT^triple": -1} |
| 13 | allTokenList = [] |
| 14 | allMessageList = [] |
| 15 | |
| 16 | regex = regexGenerator(log_format) |
| 17 | |
| 18 | for line in open(logFile, "r"): |
| 19 | tokens, message = tokenSpliter(line, regex, rex) |
| 20 | allMessageList.append(message) |
| 21 | if tokens == None: |
| 22 | pass |
| 23 | else: |
| 24 | allTokenList.append(tokens) |
| 25 | for index in range(len(tokens)): |
| 26 | if index >= len(tokens) - 2: |
| 27 | break |
| 28 | tripleTmp = ( |
| 29 | tokens[index] + "^" + tokens[index + 1] + "^" + tokens[index + 2] |
| 30 | ) |
| 31 | if tripleTmp in triDictionaryList: |
| 32 | triDictionaryList[tripleTmp] = triDictionaryList[tripleTmp] + 1 |
| 33 | else: |
| 34 | triDictionaryList[tripleTmp] = 1 |
| 35 | for index in range(len(tokens)): |
| 36 | if index == len(tokens) - 1: |
| 37 | doubleTmp = tokens[index] + "^" + tokens[0] |
| 38 | if doubleTmp in doubleDictionaryList: |
| 39 | doubleDictionaryList[doubleTmp] = ( |
| 40 | doubleDictionaryList[doubleTmp] + 1 |
| 41 | ) |
| 42 | else: |
| 43 | doubleDictionaryList[doubleTmp] = 1 |
| 44 | break |
| 45 | doubleTmp = tokens[index] + "^" + tokens[index + 1] |
| 46 | if doubleTmp in doubleDictionaryList: |
| 47 | doubleDictionaryList[doubleTmp] = ( |
| 48 | doubleDictionaryList[doubleTmp] + 1 |
| 49 | ) |
| 50 | else: |
| 51 | doubleDictionaryList[doubleTmp] = 1 |
| 52 | |
| 53 | return doubleDictionaryList, triDictionaryList, allTokenList, allMessageList |
no test coverage detected