wam: Add --datadir option to set the path to the Wesnoth data dir

[ci skip]

This is needed to use the 1.13.x WAM with older versions without messing
up icons due to files that have been moved or deleted over time.
This commit is contained in:
Ignacio R. Morelle 2017-10-10 14:53:02 -03:00
parent 1383635ff0
commit cd23596993
2 changed files with 6 additions and 3 deletions

View file

@ -184,7 +184,7 @@ def urlencode(text):
return text
return urllib.parse.quote(text, encoding='utf-8')
def output(path, url, data):
def output(path, url, datadir, data):
"""Write the HTML index of add-ons into the specified directory."""
try:
os.mkdir(path)
@ -197,7 +197,7 @@ def output(path, url, data):
outfile.write(line + "\n")
am_dir = os.path.dirname(__file__) + "/"
root_dir = am_dir + "../../../"
root_dir = datadir + "/" if datadir is not None else am_dir + "../../../"
images_to_tc = []
# Copy required HTML assets into the destination dir.

View file

@ -82,6 +82,9 @@ if __name__ == "__main__":
argumentparser.add_argument("--url", help="When used with --html, " +
"a download link will be added for each campaign, with the given " +
"base URL.")
argumentparser.add_argument("--datadir", help="When used with --html, " +
"specifies the Wesnoth data dir where add-on icons will be copied " +
"from.")
argumentparser.add_argument("-U", "--unpack",
help="unpack the file UNPACK as a binary WML packet " +
"(specify the add-on path with -c)")
@ -412,7 +415,7 @@ if __name__ == "__main__":
del cs
if campaign_list:
import addon_manager.html
addon_manager.html.output(args.html, args.url,
addon_manager.html.output(args.html, args.url, args.datadir,
campaign_list)
else:
sys.stderr.write("Could not retrieve campaign list " +