wmlunits: used os.path.join() to build paths instead of string concatenation
This commit is contained in:
parent
888218c446
commit
f1fb3a73a8
1 changed files with 16 additions and 17 deletions
|
@ -30,8 +30,7 @@ TIMEOUT = 20
|
|||
def copy_images():
|
||||
print("Recolorizing pictures.")
|
||||
image_collector.copy_and_color_images(options.output)
|
||||
shutil.copy2(os.path.join(os.path.dirname(os.path.realpath(__file__)),
|
||||
"unit_tree/menu.js"),
|
||||
shutil.copy2(os.path.join(os.path.dirname(os.path.realpath(__file__)), "unit_tree", "menu.js"),
|
||||
options.output)
|
||||
|
||||
def shell_out(com):
|
||||
|
@ -54,7 +53,7 @@ def get_info(addon):
|
|||
return _info[addon]
|
||||
_info[addon] = None
|
||||
try:
|
||||
path = options.addons + "/" + addon + "/_info.cfg"
|
||||
path = os.path.join(options.addons, addon, "_info.cfg")
|
||||
if os.path.exists(path):
|
||||
parser = wmlparser3.Parser(options.wesnoth,
|
||||
options.config_dir,
|
||||
|
@ -241,7 +240,7 @@ def list_contents():
|
|||
return info.get_text_val("version") + "*" + info.get_text_val("uploads")
|
||||
|
||||
try:
|
||||
os.makedirs(options.output + "/mainline")
|
||||
os.makedirs(os.path.join(options.output, "mainline"))
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
@ -282,7 +281,7 @@ def list_contents():
|
|||
addons = sorted_by_dependencies(addons)
|
||||
|
||||
for i, addon in enumerate(addons):
|
||||
if not os.path.isdir(options.addons + "/" + addon):
|
||||
if not os.path.isdir(os.path.join(options.addons, addon)):
|
||||
continue
|
||||
mem = "? KB"
|
||||
try:
|
||||
|
@ -291,16 +290,16 @@ def list_contents():
|
|||
pass
|
||||
sys.stdout.write("%4d/%4d " % (1 + i, len(addons)) + addon + " [" + mem + "] ... ")
|
||||
sys.stdout.flush()
|
||||
d = options.output + "/" + addon
|
||||
logname = d + "/error.log"
|
||||
d = os.path.join(options.output, addon)
|
||||
logname = os.path.join(d, "error.log")
|
||||
try:
|
||||
os.makedirs(d)
|
||||
except OSError:
|
||||
pass
|
||||
version = get_version(addon)
|
||||
move(options.addons, options.config_dir + "/data/add-ons", addon)
|
||||
move(options.addons, os.path.join(options.config_dir, "data", "add-ons"), addon)
|
||||
for d in get_dependencies(addon):
|
||||
move(options.addons, options.config_dir + "/data/add-ons", d)
|
||||
move(options.addons, os.path.join(options.config_dir, "data", "add-ons"), d)
|
||||
try:
|
||||
info = search(batchlist, addon)
|
||||
if info.get("version", "") == version and info.get("parsed", False) is True:
|
||||
|
@ -335,9 +334,9 @@ def list_contents():
|
|||
ef.close()
|
||||
sys.stdout.write("failed\n")
|
||||
finally:
|
||||
move(options.config_dir + "/data/add-ons", options.addons, addon)
|
||||
move(os.path.join(options.config_dir, "data", "add-ons"), options.addons, addon)
|
||||
for d in get_dependencies(addon):
|
||||
move(options.config_dir + "/data/add-ons", options.addons, d)
|
||||
move(os.path.join(options.config_dir, "data", "add-ons"), options.addons, d)
|
||||
|
||||
yaml.safe_dump(batchlist, open(filename, "w"),
|
||||
encoding="utf-8", default_flow_style=False)
|
||||
|
@ -429,18 +428,18 @@ def batch_process():
|
|||
worked = True
|
||||
else:
|
||||
try:
|
||||
move(options.addons, options.config_dir + "/data/add-ons", name)
|
||||
move(options.addons, os.path.join(options.config_dir, "data", "add-ons"), name)
|
||||
worked = True
|
||||
except FileNotFoundError:
|
||||
worked = False
|
||||
for d in addon.get("dependencies", []):
|
||||
move(options.addons, options.config_dir + "/data/add-ons", d)
|
||||
d = options.output + "/" + name
|
||||
move(options.addons, os.path.join(options.config_dir, "data", "add-ons"), d)
|
||||
d = os.path.join(options.output, name)
|
||||
try:
|
||||
os.makedirs(d)
|
||||
except OSError:
|
||||
pass
|
||||
logname = d + "/error.log"
|
||||
logname = os.path.join(d, "error.log")
|
||||
|
||||
def err(mess):
|
||||
ef = open(logname, "a")
|
||||
|
@ -486,9 +485,9 @@ def batch_process():
|
|||
ef.close()
|
||||
finally:
|
||||
if name != "mainline":
|
||||
move(options.config_dir + "/data/add-ons", options.addons, name)
|
||||
move(os.path.join(options.config_dir, "data", "add-ons"), options.addons, name)
|
||||
for d in addon.get("dependencies", []):
|
||||
move(options.config_dir + "/data/add-ons", options.addons, d)
|
||||
move(os.path.join(options.config_dir, "data", "add-ons"), options.addons, d)
|
||||
|
||||
addon["parsed"] = True
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue