| Total Complexity | 5 |
| Total Lines | 20 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | from rest_framework import serializers |
||
| 15 | class BasePipeline(object): |
||
| 16 | steps = None |
||
| 17 | |||
| 18 | def __init__(self, request, steps=None): |
||
| 19 | self._request = request |
||
| 20 | if steps is not None: |
||
| 21 | self.steps = steps |
||
| 22 | |||
| 23 | def run(self): |
||
| 24 | assert self.steps is not None, ( |
||
| 25 | 'Pipeline `steps` have not been specified. ' |
||
| 26 | 'They are required to run the pipeline.' |
||
| 27 | ) |
||
| 28 | |||
| 29 | context = {'request': self._request} |
||
| 30 | for step_func in self.steps: |
||
| 31 | step_context = step_func(**context) or {} |
||
| 32 | context.update(step_context) |
||
| 33 | |||
| 34 | return context |
||
| 35 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.