From 64f8613389e8ffeaf26170860022f9c7b621c7d8 Mon Sep 17 00:00:00 2001 From: allexio-bot Date: Sun, 4 Apr 2021 10:51:29 +0200 Subject: [PATCH] Implemented Facebook data validation --- src/fb_data_analyser.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/fb_data_analyser.py b/src/fb_data_analyser.py index c9ee4ad..4475d55 100644 --- a/src/fb_data_analyser.py +++ b/src/fb_data_analyser.py @@ -35,11 +35,15 @@ def zip_opener(zip_path: str): def validate_uploaded_data(): """ Checks that the selected directory conforms to what is expected from a facebook data folder. """ - data_valid = True - # TODO: actually implement data validator. - if not data_valid: + temp_path = os.getcwd() + "/temp" + temp_dir_list = os.listdir(temp_path) + if "index.html" in temp_dir_list: + delete_temp() + showerror("Error", "Data uploaded is in HTML format. Please download your Facebook data in JSON format, as this is what this tool requires.") + exit(1) + if "profile_information" not in temp_dir_list: delete_temp() - showerror("Error", "Data uploaded is not valid Facebook data.") + showerror("Error", "Data uploaded is not valid Facebook data. Please check the README for instructions on how data should be zipped.") exit(1) def delete_temp():