From b2ae164c1a9ff19c165225e123e76751a84563a8 Mon Sep 17 00:00:00 2001 From: Andreas Berg Date: Wed, 17 Jul 2024 14:00:14 +0200 Subject: [PATCH] linting --- src/webapp/api.py | 6 ++++-- src/webapp/models.py | 4 +++- src/webapp/storage.py | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/webapp/api.py b/src/webapp/api.py index a41f6d5..05b14d9 100644 --- a/src/webapp/api.py +++ b/src/webapp/api.py @@ -209,8 +209,10 @@ def get_example_drawings(json_data): if (lang == "NO"): label = models.to_english(label) - example_drawing_urls = models.get_n_random_example_images(label, number_of_images) - example_drawings = storage.get_images_from_relative_url(example_drawing_urls) + example_drawing_urls = models.get_n_random_example_images( + label, number_of_images) + example_drawings = storage.get_images_from_relative_url( + example_drawing_urls) emit("getExampleDrawings", json.dumps(example_drawings), room=game_id) diff --git a/src/webapp/models.py b/src/webapp/models.py index 9017c8e..75e8c56 100644 --- a/src/webapp/models.py +++ b/src/webapp/models.py @@ -115,6 +115,7 @@ class Difficulty(db.Model): id = db.Column(db.Integer, primary_key=True) difficulty = db.Column(db.String(32), nullable=False) + class ExampleImages(db.Model): """ Model for storing example image urls that the model has predicted correctly. @@ -589,6 +590,7 @@ def get_translation_dict(): except Exception as e: raise Exception("Could not read Labels table: " + str(e)) + def insert_into_example_images(images, label): """ Insert values into ExampleImages table. @@ -638,4 +640,4 @@ def populate_example_images(app): db.session.commit() except Exception as e: raise Exception( - "Could not insert into ExampleImages table: " + str(e)) \ No newline at end of file + "Could not insert into ExampleImages table: " + str(e)) diff --git a/src/webapp/storage.py b/src/webapp/storage.py index e7d4c41..bcdf7b1 100644 --- a/src/webapp/storage.py +++ b/src/webapp/storage.py @@ -143,6 +143,7 @@ def image_to_data_url(image_data, content_type): base64_image = base64.b64encode(image_data).decode('utf-8') return f"data:{content_type};base64,{base64_image}" + def get_images_from_relative_url(image_urls): """ Returns a list of images from a list of relative URLs. @@ -156,4 +157,4 @@ def get_images_from_relative_url(image_urls): decoded_image = image_to_data_url( image_data, "application/octet-stream") images.append(decoded_image) - return images \ No newline at end of file + return images