prog
This commit is contained in:
19
tools/item/csv/__main__.py
Normal file
19
tools/item/csv/__main__.py
Normal file
@@ -0,0 +1,19 @@
|
||||
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")
|
||||
Reference in New Issue
Block a user