From e121afdbea6dc752a959d22d2f88a7e8ba8ccc41 Mon Sep 17 00:00:00 2001 From: "Antonio J. Delgado" Date: Mon, 6 Sep 2021 16:54:51 +0300 Subject: [PATCH] Add function to test for json string --- image_classifier/image_classifier.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/image_classifier/image_classifier.py b/image_classifier/image_classifier.py index bc39a15..61fefff 100755 --- a/image_classifier/image_classifier.py +++ b/image_classifier/image_classifier.py @@ -68,12 +68,15 @@ class image_classifier: people = self.find_faces(file) if people: self._log.debug(f"Found {len(people)} known people in the image.") + self._log.debug(json.dumps(people, indent=2)) with open(file, 'rb') as image_file: exif_info = exif.Image(image_file) if exif_info.has_exif: for key in exif_info.list_all(): if key != 'cannot read a base/unknown IFD tag instance': - print(f"{key}: {exif_info[key]}") + sys.stdout.write(f"{key}: ") + sys.stdout.write(exif_info[key]) + #exif_info["user_comment"] else: self._log.debug("No exif info in the image.") # get date @@ -81,6 +84,10 @@ class image_classifier: else: self._log.debug("Doesn't seem to be an image.") + def is_json(self, data): + result = json.loads(data) + return True + def load_known_people(self): known_people = list() self._log.debug(f"Looking for known faces in directory '{self.faces_directory}'...")