Strengthen type of Card::avatar from str to Path
This commit is contained in:
parent
cf36808e55
commit
e5acf26d7e
|
@ -111,7 +111,7 @@ def get_orig_avatar(
|
||||||
return result.content
|
return result.content
|
||||||
|
|
||||||
|
|
||||||
def get_avatar(url: str, secrets: dict[str, str]) -> str | None:
|
def get_avatar(url: str, secrets: dict[str, str]) -> Path | None:
|
||||||
basename = hashlib.sha256(url.encode("utf-8")).hexdigest()
|
basename = hashlib.sha256(url.encode("utf-8")).hexdigest()
|
||||||
file_path = cache_dir() / f"{basename}.svg"
|
file_path = cache_dir() / f"{basename}.svg"
|
||||||
if not file_path.exists():
|
if not file_path.exists():
|
||||||
|
@ -129,7 +129,7 @@ def get_avatar(url: str, secrets: dict[str, str]) -> str | None:
|
||||||
|
|
||||||
with open(file_path, "w") as svgfile:
|
with open(file_path, "w") as svgfile:
|
||||||
svgfile.write(svg_text)
|
svgfile.write(svg_text)
|
||||||
return str(file_path.relative_to(root_dir()))
|
return file_path.relative_to(root_dir())
|
||||||
|
|
||||||
|
|
||||||
def get_country_name(
|
def get_country_name(
|
||||||
|
@ -265,7 +265,7 @@ mid = secrets.get("mailer_id")
|
||||||
|
|
||||||
class Card(TypedDict):
|
class Card(TypedDict):
|
||||||
address: str
|
address: str
|
||||||
avatar: str | None
|
avatar: Path | None
|
||||||
row: dict[str, str]
|
row: dict[str, str]
|
||||||
imb: str
|
imb: str
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue