Skip to content

Commit

Permalink
fix other linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bssyousefi committed Sep 23, 2024
1 parent 8e02303 commit dfa33fd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
5 changes: 3 additions & 2 deletions examples/look/look/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import falcon

from .images import Collection, ImageStore, Item
from .images import Collection
from .images import ImageStore
from .images import Item


def create_app(image_store):
Expand All @@ -16,4 +18,3 @@ def get_app():
storage_path = os.environ.get('LOOK_STORAGE_PATH', '.')
image_store = ImageStore(storage_path)
return create_app(image_store)

16 changes: 5 additions & 11 deletions examples/look/look/images.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import io
import json
import mimetypes
import os
import re
import uuid

import json

import falcon


Expand All @@ -14,13 +13,9 @@ def __init__(self, image_store):
self._image_store = image_store

def on_get(self, req, resp):
max_size = req.get_param_as_int("maxsize", min_value=1, default=-1)
max_size = req.get_param_as_int('maxsize', min_value=1, default=-1)
images = self._image_store.list(max_size)
doc = {
'images': [
{'href': '/images/' + image} for image in images
]
}
doc = {'images': [{'href': '/images/' + image} for image in images]}

resp.text = json.dumps(doc, ensure_ascii=False)
resp.status = falcon.HTTP_200
Expand All @@ -32,7 +27,6 @@ def on_post(self, req, resp):


class Item:

def __init__(self, image_store):
self._image_store = image_store

Expand Down Expand Up @@ -82,12 +76,12 @@ def open(self, name):

def list(self, max_size):
images = [
image for image in os.listdir(self._storage_path)
image
for image in os.listdir(self._storage_path)
if self._IMAGE_NAME_PATTERN.match(image)
and (
max_size == -1
or os.path.getsize(os.path.join(self._storage_path, image)) <= max_size
)
]
return images

8 changes: 3 additions & 5 deletions examples/look/tests/test_app.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import io
import json
import os
import uuid
from unittest import TestCase
from unittest.mock import call
from unittest.mock import MagicMock
from unittest.mock import mock_open
import uuid
from wsgiref.validate import InputWrapper

import msgpack
import pytest

import falcon
Expand Down Expand Up @@ -123,8 +122,8 @@ def test_listing_images():
storage_path = '.'
file_paths = [f'{storage_path}/{name}' for name in file_names]
fake_images_bytes = [
b'fake-image-bytes', # 17
b'fake-image-bytes-with-more-length', # 34
b'fake-image-bytes', # 17
b'fake-image-bytes-with-more-length', # 34
]
for i in range(2):
with open(file_paths[i], 'wb') as image_file:
Expand All @@ -138,4 +137,3 @@ def test_listing_images():

for file_path in file_paths:
os.remove(file_path)

0 comments on commit dfa33fd

Please sign in to comment.