From e4e1e97eb4aebdac8c7836cab317c67e87efcfc6 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Thu, 10 Jan 2019 19:19:13 -0500 Subject: [PATCH] Allow generation of empty Python paks --- korman/exporter/python.py | 3 +++ korman/korlib/python.py | 4 +++- korman/operators/op_export.py | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/korman/exporter/python.py b/korman/exporter/python.py index ef87718..e397d95 100644 --- a/korman/exporter/python.py +++ b/korman/exporter/python.py @@ -149,9 +149,12 @@ class PythonPackageExporter: # DONE report.progress_end() + report.raise_errors() def _package_python(self, report): py_code = self._compyle(report) + if not py_code: + report.error("No Python files were packaged.") self._write_python_pak(py_code, report) def _write_python_pak(self, py_code, report): diff --git a/korman/korlib/python.py b/korman/korlib/python.py index f2033a9..5869539 100644 --- a/korman/korlib/python.py +++ b/korman/korlib/python.py @@ -132,7 +132,9 @@ def package_python(stream, pyc_objects): # ~~~~~ # uint32_t filesz # uint8_t data[filesz] - assert bool(pyc_objects) + if not pyc_objects: + stream.writeInt(0) + return # `stream` might be a plEncryptedStream, which doesn't seek very well at all. # Therefore, we will go ahead and calculate the size of the index block so diff --git a/korman/operators/op_export.py b/korman/operators/op_export.py index b83ea5c..e4df68e 100644 --- a/korman/operators/op_export.py +++ b/korman/operators/op_export.py @@ -277,6 +277,9 @@ class PlasmaPythonExportOperator(ExportOperator, bpy.types.Operator): except korlib.PythonNotAvailableError as error: self.report({"ERROR"}, "Python Version {} not found".format(error)) return {"CANCELLED"} + except exporter.NonfatalExportError as error: + self.report({"WARNING"}, str(error)) + return {"FINISHED"} else: return {"FINISHED"}