Given task name, remove repeating module names. Example: >>> remove_repeating_from_task( ... 'tasks.add', ... 'tasks.add(2, 2), tasks.mul(3), tasks.div(4)') 'tasks.add(2, 2), mul(3), div(4)'
(task_name: str, s: str)
| 139 | |
| 140 | |
| 141 | def remove_repeating_from_task(task_name: str, s: str) -> str: |
| 142 | """Given task name, remove repeating module names. |
| 143 | |
| 144 | Example: |
| 145 | >>> remove_repeating_from_task( |
| 146 | ... 'tasks.add', |
| 147 | ... 'tasks.add(2, 2), tasks.mul(3), tasks.div(4)') |
| 148 | 'tasks.add(2, 2), mul(3), div(4)' |
| 149 | """ |
| 150 | # This is used by e.g. repr(chain), to remove repeating module names. |
| 151 | # - extract the module part of the task name |
| 152 | module = str(task_name).rpartition('.')[0] + '.' |
| 153 | return remove_repeating(module, s) |
| 154 | |
| 155 | |
| 156 | def remove_repeating(substr: str, s: str) -> str: |
no test coverage detected