283 | | Below, we present a very simple example, which extends Orio with a new module that simply rewrites the annotated code without applying any code transformations at all. The new module has no parser component since there is no necessity to extract information from the annotated code, significantly simplifying the module implementation. First, we need to create a new subdirectory (with a name `simplyrewrite`, for instance) inside `src/module`. And then, we create an ''empty'' special file `__init__.py` inside directory `src/module/simplyrewrite`, so that Python will know that this folder is a package (i.e. a Python module). |
| 283 | Below, we present a very simple example, which extends Orio with a new module that simply rewrites the annotated code without applying any code transformations at all. The new module has no parser component since there is no necessity to extract information from the annotated code, significantly simplifying the module implementation. First, we need to create a new subdirectory (with a name `simplyrewrite`, for instance) inside `src/module`. And then, we create an ''empty'' special file `__init__.py` inside directory `src/module/simplyrewrite`, so that Python will know that this folder is a package (i.e. a Python module). After that, a file named `simplyrewrite.py` that contains the implementation of the transformation module class must be defined in directory `src/module/simplyrewrite`. So, here is how the new directory structure will look like after applying the transformation module extension. |
| 284 | |
| 285 | {{{ |
| 286 | % pwd |
| 287 | /home/username/orio |
| 288 | |
| 289 | % tree src/module/ |
| 290 | src/module/ |
| 291 | |-- __init__.py |
| 292 | |-- module.py |
| 293 | `-- simplyrewrite |
| 294 | |-- __init__.py |
| 295 | `-- simplyrewrite.py |
| 296 | |
| 297 | 1 directories, 4 files |
| 298 | }}} |
| 299 | |
| 300 | And, below is the complete code of the `SimplyRewrite` class. |