Files
dusk/tools/asset/bundle/__main__.py
Dominic Masters d788de8637
Some checks failed
Build Dusk / run-tests (push) Successful in 1m56s
Build Dusk / build-linux (push) Successful in 1m44s
Build Dusk / build-psp (push) Failing after 1m35s
Starting refactor of tools, thank gosh
2026-01-25 21:07:31 -06:00

66 lines
1.8 KiB
Python

import sys, os
from tools.assetstool.args import args
from tools.assetstool.processasset import processAsset
from tools.assetstool.processpalette import processPaletteList
from tools.assetstool.processtileset import processTilesetList
from tools.assetstool.processlanguage import processLanguageList
from tools.assetstool.assethelpers import getBuiltAssetsRelativePath
import zipfile
# Parse input file args.
inputAssets = []
for inputArg in args.input:
files = inputArg.split('$')
for file in files:
if str(file).strip() == '':
continue
pieces = file.split('#')
if len(pieces) < 2:
print(f"Error: Invalid input asset format '{file}'. Expected format: type#path[#option1%option2...]")
sys.exit(1)
options = {}
if len(pieces) > 2:
optionParts = pieces[2].split('%')
for part in optionParts:
partSplit = part.split('=')
if len(partSplit) < 1:
continue
if len(partSplit) == 2:
options[partSplit[0]] = partSplit[1]
else:
options[partSplit[0]] = True
inputAssets.append({
'type': pieces[0],
'path': pieces[1],
'options': options
})
if not inputAssets:
print("Error: No input assets provided.")
sys.exit(1)
# Process each asset.
files = []
for asset in inputAssets:
asset = processAsset(asset)
files.extend(asset['files'])
# Generate additional files
files.extend(processLanguageList()['files'])
# Take assets and add to a zip archive.
outputFileName = args.output_file
print(f"Creating output file: {outputFileName}")
with zipfile.ZipFile(outputFileName, 'w') as zipf:
for file in files:
relativeOutputPath = getBuiltAssetsRelativePath(file)
zipf.write(file, arcname=relativeOutputPath)
# Generate additional headers.
processPaletteList()
processTilesetList()