@@ -102,6 +102,7 @@ def __init__(self, parent=None, name=None):
102102 self .bases = []
103103 self .modifiers = set ()
104104 self .preamble = []
105+ self .epilogue = []
105106 self .lines = []
106107 self .type = None
107108 self .variables = set ()
@@ -341,6 +342,11 @@ def setName(self, name):
341342 self .name = name
342343
343344 def fixSwitch (self , block ):
345+ """ fixes the first clause in an generated switch statement
346+
347+ @param block Statement instance and child of this block
348+ @return None
349+ """
344350 lines = self .lines
345351 if (not block in lines ) or (block .name != 'if' ):
346352 return
@@ -380,15 +386,28 @@ def writeTo(self, output, indent):
380386 @param indent indentation level of this block
381387 @return None
382388 """
383- for preambles in self .config .all ('modulePreamble' , []):
384- for line in preambles :
389+ self .writeExtraLines ('modulePreamble' , output )
390+ output .write ('\n ' )
391+ Source .writeTo (self , output , indent )
392+ self .writeExtraLines ('moduleEpilogue' , output )
393+
394+ def writeExtraLines (self , name , output ):
395+ """ writes an sequence of lines given a config attribute name
396+
397+ Lines may be callable. Refer to the defaultconfig module for
398+ details.
399+
400+ @param name configuration module attribute
401+ @param output writable file-like object
402+ @return None
403+ """
404+ for lines in self .config .all (name , []):
405+ for line in lines :
385406 try :
386407 line = line (self )
387408 except (TypeError , ):
388409 pass
389410 output .write ('%s\n ' % (line , ))
390- output .write ('\n ' )
391- Source .writeTo (self , output , indent )
392411
393412
394413class Class (Source ):
0 commit comments