Ejemplo n.º 1
0
 def generate(self, writer, phase=None):
     self.chars = PSPUtils.normalizeIndentation(self.chars)
     if writer._useBraces:
         # Send lines to be output by the braces generator:
         bc = BraceConverter.BraceConverter()
         lines = PSPUtils.splitLines(PSPUtils.removeQuotes(self.chars))
         for line in lines:
             bc.parseLine(line, writer)
         return
     # Check for whitespace at the beginning and if less than 2 spaces, remove:
     if self.chars.startswith(' ') and not self.chars.startswith('  '):
         self.chars = self.chars.lstrip()
     lines = PSPUtils.splitLines(PSPUtils.removeQuotes(self.chars))
     if not lines:
         return  # ignore any empty tag
     # userIndent check
     if lines[-1].endswith('$'):
         lastline = lines[-1] = lines[-1][:-1]
         if not lastline:
             lastline = lines[-2]  # handle endscript marker on its own line
         count = 0
         while lastline[count].isspace():
             count += 1
         userIndent = lastline[:count]
     else:
         userIndent = writer._emptyString
         lastline = lines[-1]
     # Print out code (moved from above):
     writer._userIndent = writer._emptyString  # reset to none
     writer.printList(lines)
     writer.printChars('\n')
     # Check for a block:
     commentstart = lastline.find('#')  # @@ this fails if '#' part of string
     if commentstart >= 0:
         lastline = lastline[:commentstart]
     blockcheck = lastline.rstrip()
     if blockcheck.endswith(':'):
         writer.pushIndent()
         writer.println()
         writer._blockcount = writer._blockcount+1
         # Check for end of block, "pass" by itself:
     if self.chars.strip() == 'pass' and writer._blockcount > 0:
         writer.popIndent()
         writer.println()
         writer._blockcount -= 1
     # Set userIndent for subsequent HTML:
     writer._userIndent = userIndent
Ejemplo n.º 2
0
	def generate(self, writer, phase=None):
		writer.println('# Class level user code\n')
		pySrc = PSPUtils.normalizeIndentation(self.chars, writer._indent)
		pySrc = PSPUtils.splitLines(PSPUtils.removeQuotes(pySrc))
		writer.printList(pySrc)