diff --git a/Exporter.exe b/Exporter.exe index 22dabab..6127241 100755 --- a/Exporter.exe +++ b/Exporter.exe Binary files differ diff --git a/Exporter.exe b/Exporter.exe index 22dabab..6127241 100755 --- a/Exporter.exe +++ b/Exporter.exe Binary files differ diff --git a/Exporter.swf b/Exporter.swf index 3deab40..3870680 100644 --- a/Exporter.swf +++ b/Exporter.swf Binary files differ diff --git a/Exporter.exe b/Exporter.exe index 22dabab..6127241 100755 --- a/Exporter.exe +++ b/Exporter.exe Binary files differ diff --git a/Exporter.swf b/Exporter.swf index 3deab40..3870680 100644 --- a/Exporter.swf +++ b/Exporter.swf Binary files differ diff --git a/job.py b/job.py index e8f768f..665d9f0 100644 --- a/job.py +++ b/job.py @@ -64,17 +64,26 @@ return {"graphics":[g.get_cmd() for g in self.graphics], "id":self.id} def write_results(self, data, resources): + base_path = os.path.join(self.out_dir, self.rel_path) + if not os.path.exists(base_path): + os.makedirs(base_path) for i,r in enumerate(resources): - path = os.path.join(self.out_dir, self.rel_path, "%s_%04d.png" % (self.name, i)) + path = os.path.join(base_path, "%s_%04d.png" % (self.name, i)) with open(path, "wb") as f: f.write(base64.b64decode(r)) print "resource file: " + path - for name,details in data.iteritems(): - if len(data) == 1: - pass - else: - pass - + if len(data) == 1: + graphic_and_asset = {} + (name, graphic_data) = data.items()[0] + graphic_and_asset = {"data":graphic_data} + with open(os.path.join(base_path, name + ".graphic"), "w") as f: + f.write(pretty_dumps(graphic_and_asset)) + else: + with open(os.path.join(base_path, self.name + ".asset"), "w") as f: + f.write(json.pretty_dumps(data)) + for name,details in data.iteritems(): + with open(os.path.join(base_path, name + ".graphic"), "w") as f: + f.write(json.pretty_dumps(details)) class Graphic: def __init__(self, folder, json): diff --git a/Exporter.exe b/Exporter.exe index 22dabab..6127241 100755 --- a/Exporter.exe +++ b/Exporter.exe Binary files differ diff --git a/Exporter.swf b/Exporter.swf index 3deab40..3870680 100644 --- a/Exporter.swf +++ b/Exporter.swf Binary files differ diff --git a/job.py b/job.py index e8f768f..665d9f0 100644 --- a/job.py +++ b/job.py @@ -64,17 +64,26 @@ return {"graphics":[g.get_cmd() for g in self.graphics], "id":self.id} def write_results(self, data, resources): + base_path = os.path.join(self.out_dir, self.rel_path) + if not os.path.exists(base_path): + os.makedirs(base_path) for i,r in enumerate(resources): - path = os.path.join(self.out_dir, self.rel_path, "%s_%04d.png" % (self.name, i)) + path = os.path.join(base_path, "%s_%04d.png" % (self.name, i)) with open(path, "wb") as f: f.write(base64.b64decode(r)) print "resource file: " + path - for name,details in data.iteritems(): - if len(data) == 1: - pass - else: - pass - + if len(data) == 1: + graphic_and_asset = {} + (name, graphic_data) = data.items()[0] + graphic_and_asset = {"data":graphic_data} + with open(os.path.join(base_path, name + ".graphic"), "w") as f: + f.write(pretty_dumps(graphic_and_asset)) + else: + with open(os.path.join(base_path, self.name + ".asset"), "w") as f: + f.write(json.pretty_dumps(data)) + for name,details in data.iteritems(): + with open(os.path.join(base_path, name + ".graphic"), "w") as f: + f.write(json.pretty_dumps(details)) class Graphic: def __init__(self, folder, json): diff --git a/validate.py b/validate.py index aba3988..10e15d5 100644 --- a/validate.py +++ b/validate.py @@ -1,5 +1,9 @@ from jsonschema import validators, Draft7Validator import jsonschema +import json + +def pretty_dumps(obj): + return json.dumps(obj, sort_keys=True, indent=2) def extend_with_default(validator_class): validate_properties = validator_class.VALIDATORS["properties"]