Multiple exclude files can be given
Signed-off-by: merspieler <merspieler@airmail.cc>
This commit is contained in:
parent
1bc5bb39e0
commit
adda3594b6
1 changed files with 23 additions and 5 deletions
|
@ -25,6 +25,7 @@ import time
|
||||||
chunk_size = 5
|
chunk_size = 5
|
||||||
threads = 5
|
threads = 5
|
||||||
cont = 0
|
cont = 0
|
||||||
|
exclude = []
|
||||||
|
|
||||||
argc = len(sys.argv)
|
argc = len(sys.argv)
|
||||||
i = 1
|
i = 1
|
||||||
|
@ -39,6 +40,18 @@ while i < argc:
|
||||||
elif sys.argv[i] == "-t" or sys.argv[i] == "--threads":
|
elif sys.argv[i] == "-t" or sys.argv[i] == "--threads":
|
||||||
i += 1
|
i += 1
|
||||||
threads = sys.argv[i]
|
threads = sys.argv[i]
|
||||||
|
elif sys.argv[i] == "-e" or sys.argv[i] == "--exclude":
|
||||||
|
i += 1
|
||||||
|
if os.path.isfile(sys.argv[i]):
|
||||||
|
try:
|
||||||
|
with open(sys.argv[i]) as json_data:
|
||||||
|
exclude += json.load(json_data)
|
||||||
|
except ValueError:
|
||||||
|
print("Exclude file '" + sys.argv[i] + "' is no proper JSON file.")
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
print("File not found: " + sys.argv[i])
|
||||||
|
sys.exit(1)
|
||||||
elif sys.argv[i] == "-p" or sys.argv[i] == "--progress":
|
elif sys.argv[i] == "-p" or sys.argv[i] == "--progress":
|
||||||
try:
|
try:
|
||||||
with open("projects/worldbuild/done") as f:
|
with open("projects/worldbuild/done") as f:
|
||||||
|
@ -99,6 +112,9 @@ while i < argc:
|
||||||
print(" -s, --chunk-size Sets chunk size, default 5")
|
print(" -s, --chunk-size Sets chunk size, default 5")
|
||||||
print(" -t, --threads Number of threads to run")
|
print(" -t, --threads Number of threads to run")
|
||||||
print(" -c, --continue Contine build from tile number <n>")
|
print(" -c, --continue Contine build from tile number <n>")
|
||||||
|
print(" -e, --exclude Files containing JSON array naming tiles not to be build")
|
||||||
|
print(" Can be used multiple times.")
|
||||||
|
print(" If not given projects/worldbuild/exclude will be used")
|
||||||
print(" -h, --help Shows this help and exit")
|
print(" -h, --help Shows this help and exit")
|
||||||
print(" -p, --progress Shows progress and exit")
|
print(" -p, --progress Shows progress and exit")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
@ -191,11 +207,13 @@ def print_build_time(start_time, end_time):
|
||||||
print("Running worldbuild took " + time)
|
print("Running worldbuild took " + time)
|
||||||
|
|
||||||
# Get exclude file
|
# Get exclude file
|
||||||
if os.path.isfile("projects/worldbuild/exclude"):
|
if os.path.isfile("projects/worldbuild/exclude") and exclude == []:
|
||||||
|
try:
|
||||||
with open("projects/worldbuild/exclude") as json_data:
|
with open("projects/worldbuild/exclude") as json_data:
|
||||||
exclude = json.load(json_data)
|
exclude = json.load(json_data)
|
||||||
else:
|
except ValueError:
|
||||||
exclude = []
|
print("Exclude file 'projects/worldbuild/exclude' is no proper JSON file.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue