mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-11-22 15:53:01 +00:00
python "black" formatting
This commit is contained in:
parent
48f58a7953
commit
5a07ca5dfd
6 changed files with 31 additions and 30 deletions
4
api/.flake8
Normal file
4
api/.flake8
Normal file
|
@ -0,0 +1,4 @@
|
|||
[flake8]
|
||||
max-line-length = 80
|
||||
select = C,E,F,W,B,B950
|
||||
extend-ignore = E203, E501
|
|
@ -6,22 +6,20 @@ from webdav3.client import Client as WebDAVclient
|
|||
|
||||
from .settings import SETTINGS
|
||||
|
||||
_WEBDAV_CLIENT = WebDAVclient({
|
||||
_WEBDAV_CLIENT = WebDAVclient(
|
||||
{
|
||||
"webdav_hostname": SETTINGS.webdav.url,
|
||||
"webdav_login": SETTINGS.webdav.username,
|
||||
"webdav_password": SETTINGS.webdav.password,
|
||||
"disable_check": SETTINGS.webdav.disable_check,
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@AsyncTTL(time_to_live=SETTINGS.cache_ttl)
|
||||
async def dav_list_files(regex: re.Pattern, directory: str = "") -> list[str]:
|
||||
ls = _WEBDAV_CLIENT.list(directory)
|
||||
return [
|
||||
f"{directory}/{path}"
|
||||
for path in ls
|
||||
if regex.search(path)
|
||||
]
|
||||
return [f"{directory}/{path}" for path in ls if regex.search(path)]
|
||||
|
||||
|
||||
@AsyncTTL(time_to_live=SETTINGS.cache_ttl)
|
||||
|
|
|
@ -25,12 +25,14 @@ class AdventImage:
|
|||
square = min(width, height)
|
||||
|
||||
# Bild zuschneiden und skalieren
|
||||
img = img.crop(box=(
|
||||
img = img.crop(
|
||||
box=(
|
||||
int((width - square) / 2),
|
||||
int((height - square) / 2),
|
||||
int((width + square) / 2),
|
||||
int((height + square) / 2),
|
||||
))
|
||||
)
|
||||
)
|
||||
|
||||
img = img.resize(
|
||||
size=(500, 500),
|
||||
|
@ -80,7 +82,7 @@ class AdventImage:
|
|||
"""
|
||||
|
||||
pixel_data = self.img.crop(box).getdata()
|
||||
mean_color: np.ndarray = np.mean(pixel_data, axis=0)
|
||||
mean_color: np.ndarray = np.mean(a=pixel_data, axis=0)
|
||||
|
||||
return tuple(mean_color.astype(int).tolist())
|
||||
|
||||
|
@ -99,11 +101,7 @@ class AdventImage:
|
|||
|
||||
# betroffenen Bildbereich bestimmen
|
||||
text_box = await self.get_text_box(
|
||||
xy=xy,
|
||||
text=text,
|
||||
font=font,
|
||||
anchor=anchor,
|
||||
**text_kwargs
|
||||
xy=xy, text=text, font=font, anchor=anchor, **text_kwargs
|
||||
)
|
||||
|
||||
if text_box is not None:
|
||||
|
@ -132,5 +130,5 @@ class AdventImage:
|
|||
font=font,
|
||||
fill=text_color,
|
||||
anchor=anchor,
|
||||
**text_kwargs
|
||||
**text_kwargs,
|
||||
)
|
||||
|
|
|
@ -36,6 +36,7 @@ async def shuffle(seq: Sequence, rnd: random.Random | None = None) -> list:
|
|||
# Elemente mischen
|
||||
return rnd.sample(seq, len(seq))
|
||||
|
||||
|
||||
#########
|
||||
# IMAGE #
|
||||
#########
|
||||
|
|
|
@ -22,8 +22,10 @@ async def uwe(
|
|||
) -> str:
|
||||
kurix = await get_kurix(kgs)
|
||||
|
||||
return f"UWE hat bei {firma} einen beachtlichen Haufen von " \
|
||||
return (
|
||||
f"UWE hat bei {firma} einen beachtlichen Haufen von "
|
||||
f"{kgs} Kg ({kurix:.3f} Kurix) auf den Läufer geschissen."
|
||||
)
|
||||
|
||||
|
||||
@router.get("/torsten/{ding}")
|
||||
|
@ -41,8 +43,8 @@ async def torsten(ding: str) -> str:
|
|||
status.HTTP_418_IM_A_TEAPOT: {
|
||||
"description": "Commit Sudoku",
|
||||
"content": None,
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
async def kys() -> None:
|
||||
"""
|
||||
|
|
|
@ -13,9 +13,7 @@ async def user_is_admin(
|
|||
credentials: HTTPBasicCredentials = Depends(security),
|
||||
config: Config = Depends(get_config),
|
||||
) -> bool:
|
||||
username_correct = secrets.compare_digest(
|
||||
credentials.username, config.admin.name
|
||||
)
|
||||
username_correct = secrets.compare_digest(credentials.username, config.admin.name)
|
||||
|
||||
password_correct = secrets.compare_digest(
|
||||
credentials.password, config.admin.password
|
||||
|
|
Loading…
Reference in a new issue