| 285 | {{{ |
| 286 | # |
| 287 | # File: src/module/simplyrewrite/simplyrewrite.py |
| 288 | # |
| 289 | |
| 290 | import module.module |
| 291 | |
| 292 | class SimplyRewrite(module.module.Module): |
| 293 | '''A simple rewriting module''' |
| 294 | |
| 295 | def __init__(self, perf_params, module_body_code, annot_body_code, cmd_line_opts, line_no, indent_size): |
| 296 | '''To instantiate a simple rewriting module''' |
| 297 | module.module.Module.__init__(self, perf_params, module_body_code, annot_body_code, |
| 298 | cmd_line_opts, line_no, indent_size) |
| 299 | |
| 300 | def transform(self): |
| 301 | '''To simply rewrite the annotated code''' |
| 302 | |
| 303 | # to create a comment containing information about the class attributes |
| 304 | comment = ''' |
| 305 | /* |
| 306 | perf_params = %s |
| 307 | module_body_code = "%s" |
| 308 | annot_body_code = "%s" |
| 309 | line_no = %s |
| 310 | indent_size = %s |
| 311 | */ |
| 312 | ''' % (self.perf_params, self.module_body_code, self.annot_body_code, self.line_no, self.indent_size) |
| 313 | |
| 314 | # to rewrite the annotated code, with the class-attribute comment being prepended |
| 315 | output_code = comment + self.annot_body_code |
| 316 | |
| 317 | # to return the output code |
| 318 | return output_code |
| 319 | }}} |