Example #1
0
 def testSplitTabs(self):
     from mineline.PreProcessLog import PreProcessLog
     # Setup
     data = ("2013/05/23(Thursday)\r\n"
     "12:00\tBob\tSome test text\r\n"
     "\r\n"
     "12:48\tJohn\tI think so too\r\n")
     data = PreProcessLog.splitLines(data)
     
     expectedData = [["2013/05/23(Thursday)"],["12:00","Bob","Some test text"],["12:48","John","I think so too"]]
     
     # Exercise
     testResult = PreProcessLog.splitTabsAndCleanBlanks(data)
     
     # Test
     self.assertEqual(testResult, expectedData, "Split Tab Data does not match expected.\nExpected:" + str(expectedData) + "\nActual:" + str(testResult))
     pass
Example #2
0
 def fromFilename(cls, filepath, savedTimeZone, progressCallback=None):
     # Open log file and read in data
     f = codecs.open(filepath, 'r', encoding='utf-8')
     with f as logfile:
         unprocessed_str = logfile.read()
     
         # Process for log objects
         processed_log, logSaveTime =  PreProcessLog.processLog(unprocessed_str, savedTimeZone, progressCallback)
         return cls(processed_log, logSaveTime)
     pass
Example #3
0
 def testProcessLines(self):
     import pytz
     from mineline.PreProcessLog import PreProcessLog
     from mineline.Events import MessageEvent
     # Setup
     data = ("2013/05/23(Thursday)\r\n"
     "12:48\tJohn\tI think so too\r\n"
     "2013/05/25(Friday)\r\n"
     "14:25\tJohn\tHello?\r\n")
     
     PreProcessLog.saveTimeZone = pytz.timezone("US/Eastern") # Set timezone so converTime() works
     data = PreProcessLog.splitLines(data)
     data = PreProcessLog.splitTabsAndCleanBlanks(data)
     data = PreProcessLog.convertTimes(data)
     
     expectedData = [MessageEvent("John", "2013/05/23 16:48 UTC", "I think so too"),
                     MessageEvent("John", "2013/05/25 18:25 UTC", "Hello?")]
     # Exercise
     log_list, saveTime = PreProcessLog.processLines(data)
     
     # Test
     self.assertEqual(log_list, expectedData)
Example #4
0
 def testSplitLines(self):
     from mineline.PreProcessLog import PreProcessLog
     # Setup
     data = ("2013/05/23(Thursday)\r\n"
     "12:00\tBob\tSome test text\r\n"
     "12:48\tJohn\tI think so too\r\n")
     
     expectedData = ["2013/05/23(Thursday)","12:00\tBob\tSome test text","12:48\tJohn\tI think so too"]
     
     # Exercise
     log_list = PreProcessLog.splitLines(data)
     
     # Test
     self.assertEqual(log_list, expectedData, "Split Line List does not match expected.\nExpected:" + str(expectedData) + "\nActual:" + str(log_list))
Example #5
0
 def testExpandDates(self):
     import pytz
     from mineline.PreProcessLog import PreProcessLog
     
     # Setup
     data = ("2013/05/23(Thursday)\r\n"
     "12:00\tBob\tSome test text\r\n"
     "12:48\tJohn\tI think so too\r\n"
     "2013/05/25(Friday)\r\n"
     "14:25\tJohn\tHello?\r\n"
     "14:28\tBob\tYo what's up?\r\n"
     "14:29\tJohn\tNot much you?\r\n")
     
     data = PreProcessLog.splitLines(data)
     data = PreProcessLog.splitTabsAndCleanBlanks(data)
     
     expectedData = [["2013/05/23 16:00 UTC","Bob","Some test text"],["2013/05/23 16:48 UTC","John","I think so too"],["2013/05/25 18:25 UTC","John","Hello?"],["2013/05/25 18:28 UTC","Bob","Yo what's up?"],["2013/05/25 18:29 UTC","John","Not much you?"]]
     
     # Exercise
     PreProcessLog.saveTimeZone = pytz.timezone("US/Eastern") # Set timezone so converTimes() works
     testResult = PreProcessLog.convertTimes(data)
     
     # Test
     self.assertEqual(testResult, expectedData, "Expanded Date result did not match expected.\nExpected:" + str(expectedData) + "\nActual:" + str(testResult))
Example #6
0
 def fromString(cls, unprocessed_str, savedTimeZone, progressCallback=None):
     processed_log, logSaveTime = PreProcessLog.processLog(unprocessed_str, savedTimeZone)
     return cls(processed_log, logSaveTime)