Change arguments for dir path

Now :
- rootdir is the directory all the img paths will be relative to ;
  defaults to '.'
- imgdir is the directory containing all required images ; defaults to
  'res/ssbu'. It is expected to hold a 'chars' directory
master
Lertsenem 2020-07-09 10:19:03 +02:00
parent d5a85266c8
commit 0f8d64a091
1 changed files with 19 additions and 15 deletions

View File

@ -1,5 +1,6 @@
import argparse
import datetime
import html
import logging
import os, os.path
import sys
@ -40,9 +41,14 @@ def main():
help = "The tournament slug or id",
)
top8_parser.add_argument(
"--resourcesdir", "-RD",
default = "res",
help = "The directories containing images and templates resources",
"--rootdir", "-RD",
default = None,
help = "The directories containing this script, defaults to '.'",
)
top8_parser.add_argument(
"--imgdir", "-ID",
default = "res/ssbu",
help = "The directories containing images",
)
top8_parser.add_argument(
"--templatesdir", "-TD",
@ -109,6 +115,10 @@ def main():
print(version.VERSION_NAME)
sys.exit(0)
# -------------------------------------------------------------------------
if args.rootdir is None:
args.rootdir = "." # TODO compute script root?
# -------------------------------------------------------------------------
if args.command not in [ "top8" ]:
parser.print_help()
@ -155,12 +165,7 @@ def main():
log.info("Génération du SVG en utilisant le template")
jj2_env = jinja2.Environment(
loader = jinja2.FileSystemLoader(
os.path.join(
args.resourcesdir,
args.templatesdir,
)
)
loader = jinja2.FileSystemLoader( args.templatesdir )
)
jj2_tpl = jj2_env.get_template(
@ -176,18 +181,17 @@ def main():
top_players.values(),
key = lambda p: p.placement,
),
"imgdir_ssbu_chars": os.path.join(
args.resourcesdir,
"ssbu",
"Super Smash Bros Ultimate",
"Fighter Portraits",
"dir_root": args.rootdir,
"dir_res_ssbu": os.path.join(
args.imgdir,
"chars",
),
}
if args.outfile is None:
args.outfile = "{}.svg".format(tournament.slug)
# TODO add png export
jj2_tpl.stream(context).dump( args.outfile )