Compare commits

..

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

View file

@ -238,24 +238,21 @@ 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 # https://help.libreoffice.org/latest/en-US/text/shared/guide/csv_params.html
export_options = ( export_options = "csv:Text - txt - csv (StarCalc):" + ",".join( # Magic CSV export string
"csv:Text - txt - csv (StarCalc):" [
+ ",".join( # Magic CSV export string str(ord(",")), # Field Separator
[ str(ord('"')), # Text Delimiter
str(ord(",")), # Field Separator "76", # Character Set - UTF-8 => 76
str(ord('"')), # Text Delimiter "", # starting line; ignored in export
"76", # Character Set - UTF-8 => 76 "", # cell format codes; ignored in export
"", # starting line; ignored in export "1033", # Language Identifier - en-US => 1033
"", # cell format codes; ignored in export "", # Quoted field as text; default False
"1033", # Language Identifier - en-US => 1033 "", # Detect special numbers; default True
"", # Quoted field as text; default False "", # Save cell contents as shown; default True
"", # Detect special numbers; default True "", # Export cell formulas; default false
"", # Save cell contents as shown; default True "", # Remove spaces; ignored in export
"", # Export cell formulas; default false "-1", # Export sheets - all sheets => -1
"", # Remove spaces; ignored in export ]
"-1", # Export sheets - all sheets => -1
]
)
) )
result = subprocess.run( result = subprocess.run(
[ [
@ -273,19 +270,6 @@ elif args.address_file.suffix == ".ods":
else: else:
raise Exception("Unknown file type for --address-file") raise Exception("Unknown file type for --address-file")
class CSVRow(TypedDict):
Name: str
Address: str
DPC: str
Country: str
Design: str
Type: str
Personalization: str
Avatar: str | None
US: str
csvfile = open(csv_filename) csvfile = open(csv_filename)
rows = csv.DictReader(csvfile) rows = csv.DictReader(csvfile)
@ -299,13 +283,12 @@ mid = secrets.get("mailer_id")
class Card(TypedDict): class Card(TypedDict):
address: str address: str
avatar: Path | None avatar: Path | None
row: CSVRow row: dict[str, str]
imb: str imb: str
cards: list[Card] = [] cards: list[Card] = []
for row in rows: for row in rows:
row = CSVRow(**row)
if row["Address"] == "": if row["Address"] == "":
continue continue
@ -318,19 +301,18 @@ for row in rows:
address = row["Address"].split("\n") + country address = row["Address"].split("\n") + country
if (avatar_url := row.get("Avatar", "")) != "": if row.get("Avatar", "") != "":
avatar = get_avatar(avatar_url, secrets) # type: ignore avatar = get_avatar(row["Avatar"], secrets)
else: else:
avatar = None avatar = None
cards.append( card: Card = {
{ "address": "\n".join(address),
"address": "\n".join(address), "avatar": avatar,
"avatar": avatar, "row": row,
"row": row, "imb": "",
"imb": "", }
} cards.append(card)
)
# Typst can't access files outside the project root, except through a symlink # Typst can't access files outside the project root, except through a symlink
# Create one in cache to use here # Create one in cache to use here