diff Resources/CodeGeneration/stonegentool.py @ 507:ce49eae4c887 bgo-commands-codegen

Codegen + Warning fixes
author Benjamin Golinvaux <bgo@osimis.io>
date Fri, 01 Mar 2019 16:18:38 +0100
parents 8b6ceae45ba0
children 7105a0bad250
line wrap: on
line diff
--- a/Resources/CodeGeneration/stonegentool.py	Tue Feb 26 21:33:16 2019 +0100
+++ b/Resources/CodeGeneration/stonegentool.py	Fri Mar 01 16:18:38 2019 +0100
@@ -6,6 +6,7 @@
 from jinja2 import Template
 from io import StringIO
 import time
+import datetime
 
 """
          1         2         3         4         5         6         7
@@ -263,13 +264,15 @@
         struct = schema[GetLongTypename(shortTypename, schema)]
         # The keys in the struct dict are the member names
         # The values in the struct dict are the member types
-        for field in struct.keys():
-          # we fill the chain of dependent types (starting here)
-          ancestors.append(shortTypename)
-          ComputeOrderFromTypeTree(
-            ancestors, genOrder, struct[field], schema)
-          # don't forget to restore it!
-          ancestors.pop()
+        if struct:
+          # we reach this if struct is not None AND not empty
+          for field in struct.keys():
+            # we fill the chain of dependent types (starting here)
+            ancestors.append(shortTypename)
+            ComputeOrderFromTypeTree(
+              ancestors, genOrder, struct[field], schema)
+            # don't forget to restore it!
+            ancestors.pop()
         
         # now we're pretty sure our dependencies have been processed,
         # we can start marking our code for generation (it might 
@@ -445,6 +448,8 @@
   obj = LoadSchema(fn)
   genOrder = ComputeRequiredDeclarationOrder(obj)
   templatingDict = ProcessSchema(obj, genOrder)
+  currentDT = datetime.datetime.now()
+  templatingDict['currentDatetime'] = str(currentDT)
   return templatingDict
 
 # +-----------------------+