Files
dusk/tools/item/csv/__main__.py
Dominic Masters d1b03c4cb3
Some checks failed
Build Dusk / run-tests (push) Failing after 1m58s
Build Dusk / build-linux (push) Failing after 1m26s
Build Dusk / build-psp (push) Failing after 1m41s
prog
2026-01-26 18:27:12 -06:00

19 lines
722 B
Python

import argparse
import os
import csv
from tools.util.type import detectType, stringToCType, typeToCType
parser = argparse.ArgumentParser(description="Item CSV to .h defines")
parser.add_argument("--csv", required=True, help="Path to item CSV file")
parser.add_argument("--output", required=True, help="Path to output .h file")
args = parser.parse_args()
# Load up CSV file.
outHeader = "#pragma once\n"
outHeader += "#include \"item/item.h\"\n\n"
with open(args.csv, newline="", encoding="utf-8") as csvfile:
reader = csv.DictReader(csvfile)
# CSV must have id and type columns.
if "id" not in reader.fieldnames or "type" not in reader.fieldnames:
raise Exception("CSV file must have 'id' and 'type' columns")