Compare commits

..

No commits in common. "f2246b832d241a36cbd42eaf8c4caf3ee0ac2a68" and "cf36808e55c1febda565f07b705980490ffc5c04" have entirely different histories.

View file

@ -111,7 +111,7 @@ def get_orig_avatar(
return result.content return result.content
def get_avatar(url: str, secrets: dict[str, str]) -> Path | None: def get_avatar(url: str, secrets: dict[str, str]) -> str | 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]) -> Path | None:
with open(file_path, "w") as svgfile: with open(file_path, "w") as svgfile:
svgfile.write(svg_text) svgfile.write(svg_text)
return file_path.relative_to(root_dir()) return str(file_path.relative_to(root_dir()))
def get_country_name( def get_country_name(
@ -237,29 +237,12 @@ cldr_root = ET.parse(
if args.address_file.suffix == ".csv": if args.address_file.suffix == ".csv":
csv_filename = args.address_file csv_filename = args.address_file
elif args.address_file.suffix == ".ods": elif args.address_file.suffix == ".ods":
# https://help.libreoffice.org/latest/en-US/text/shared/guide/csv_params.html
export_options = "csv:Text - txt - csv (StarCalc):" + ",".join( # Magic CSV export string
[
str(ord(",")), # Field Separator
str(ord('"')), # Text Delimiter
"76", # Character Set - UTF-8 => 76
"", # starting line; ignored in export
"", # cell format codes; ignored in export
"1033", # Language Identifier - en-US => 1033
"", # Quoted field as text; default False
"", # Detect special numbers; default True
"", # Save cell contents as shown; default True
"", # Export cell formulas; default false
"", # Remove spaces; ignored in export
"-1", # Export sheets - all sheets => -1
]
)
result = subprocess.run( result = subprocess.run(
[ [
"libreoffice", "libreoffice",
"--headless", "--headless",
"--convert-to", "--convert-to",
export_options, "csv:Text - txt - csv (StarCalc):44,34,76,1,,0,false,true,true,false,false,-1",
"--outdir", "--outdir",
str(cache_dir()), str(cache_dir()),
args.address_file, args.address_file,
@ -282,7 +265,7 @@ mid = secrets.get("mailer_id")
class Card(TypedDict): class Card(TypedDict):
address: str address: str
avatar: Path | None avatar: str | None
row: dict[str, str] row: dict[str, str]
imb: str imb: str