From 531cc0fd239ac909ca0138079a89eb898b16638a Mon Sep 17 00:00:00 2001 From: Niclas Dobbertin Date: Thu, 15 Jun 2023 16:29:26 +0200 Subject: reformatting --- bjoern/videoanalyse/LogParser.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'bjoern') diff --git a/bjoern/videoanalyse/LogParser.py b/bjoern/videoanalyse/LogParser.py index c580cfe..e48662c 100755 --- a/bjoern/videoanalyse/LogParser.py +++ b/bjoern/videoanalyse/LogParser.py @@ -12,6 +12,8 @@ import codecs from read_sqlite import get_url_from_sqlite from pathlib import Path +BROWSER_TITLE_SUFFIX = " - Mozilla Firefox" + # takes the log data string and returns a list of activity titles and their time windows def extract_activities(log_data): @@ -33,17 +35,15 @@ def extract_activities(log_data): # extract squared brackets per string for s in windows: if not del_flag: - print("STRING: ", s) found_brackets = reg_titles.findall(s) if found_brackets: - if found_brackets[0].endswith(" - Mozilla Firefox"): - title = found_brackets[0].replace(" - Mozilla Firefox", "") + # Only use Browser titles + if found_brackets[0].endswith(BROWSER_TITLE_SUFFIX): + title = found_brackets[0].replace(BROWSER_TITLE_SUFFIX, "") brackets.append(title) enter_exit = s.split("Enter-Exit: ")[-1] timestamps = reg_titles.findall(enter_exit) - print("ENTER: ", timestamps) for timestamp in timestamps: - print(timestamp.split("-")) t_enter, t_exit = timestamp.split("-") if not title in extracted_data: extracted_data[title] = [] @@ -54,15 +54,11 @@ def extract_activities(log_data): del_flag = False if "Restricted Windows Summary:" in s: del_flag = True - print("-------------------------FINISH----------------------------------------") - print(extracted_data) return extracted_data -# returns logged activities and their timestamps from a VP as a table def get_log_data(data_path): - # import browser history and .log files files = os.listdir(data_path) log_files = [] log_data = [] @@ -91,6 +87,7 @@ def match_urls(history_db, log): return log def generate_log(activities: dict): + # For each start time in ascending order, make an entry with title and timestamp log = [] while activities: first_title = list(activities.keys())[0] @@ -102,9 +99,6 @@ def generate_log(activities: dict): < activities[smallest_start_time[0]][smallest_start_time[1]][0] ): smallest_start_time = (title, idx) - # print( - # f"title: {smallest_start_time[0]}, time: {activities[smallest_start_time[0]][smallest_start_time[1]]}" - # ) log.append( [ activities[smallest_start_time[0]][smallest_start_time[1]][0].isoformat(), -- cgit v1.2.3