16.67%

12 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-11-10 18:56:07 +00:00

1"""Apply all pairs in patches to incoming.""" 

2 

3from collections.abc import Iterable 

4 

5from liitos import log 

6 

7 

8def apply(patches: list[tuple[str, str]], incoming: Iterable[str]) -> list[str]: 

9 """Later alligator.""" 

10 outgoing = [line for line in incoming] 

11 

12 log.info(f'applying patches to {len(outgoing)} lines of text') 

13 for this, that in patches: 

14 log.info(f' - trying any ({this}) --> ({that}) ...') 

15 for n, text in enumerate(outgoing): 

16 if this in text: 

17 log.info(f' + found match ({text})') 

18 outgoing[n] = text.replace(this, that) 

19 

20 return outgoing