34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
import os
|
|
import sys
|
|
import shutil
|
|
import argparse
|
|
import pathlib
|
|
|
|
# cli arguments
|
|
parser = argparse.ArgumentParser(
|
|
prog='package_data',
|
|
description='Creates a data package for the engine.',
|
|
epilog='Note that the engine will, by default, only read .btw packages.')
|
|
parser.add_argument('-d', '--datadir',
|
|
default='./data',
|
|
type=pathlib.Path,
|
|
help='directory containing the source data')
|
|
parser.add_argument('-o', '--outdir',
|
|
default='./',
|
|
type=pathlib.Path,
|
|
help='target directory of the resulting package file')
|
|
parser.add_argument('-n', '--name',
|
|
default='data',
|
|
help='name to be used for the package file')
|
|
parser.add_argument('-e', '--extension',
|
|
default='btw',
|
|
help='extension to be used for the package file')
|
|
args = parser.parse_args()
|
|
|
|
shutil.make_archive(f"{args.outdir}/{args.name}", 'zip', args.datadir)
|
|
shutil.move(f"{args.outdir}/{args.name}.zip",
|
|
f"{args.outdir}/{args.name}.{args.extension.removeprefix('.')}")
|
|
|
|
print('All done!')
|
|
input('Press Return to exit...')
|