def format_frame(self, body, depth, info): """ Formats the block with the code header and footer (frame) """ # Construct header and footer of the function's body header_source = self.header_template % info header = util.split_source_to_lines(header_source, depth) footer_source = self.footer_template % info footer = util.split_source_to_lines(footer_source, depth) # Construct function definition lines = header + body + footer if constants.GENERATE_DEBUG_COMMENTS: self.insert_debug_comment(lines, depth) return lines
def format(self, depth=0): lines = util.split_source_to_lines(self.data, depth) if constants.GENERATE_DEBUG_COMMENTS: self.insert_debug_comment(lines, depth) return lines
def format(self, depth=0): # Function information function_info = self.get_info() # Format the body of the function body = self.format_body(depth) # Empty function? if not body: empty_body_source = self.empty_body_template % function_info lines = util.split_source_to_lines(empty_body_source, depth) return lines # Frame the function definition lines = self.format_frame(body, depth, function_info) return lines