Coverage for src/extratools_html/cleanup.py: 50%

6 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-05-01 06:58 -0700

1from asyncio import create_subprocess_exec, subprocess 

2from asyncio.subprocess import Process 

3 

4 

5async def cleanup_page(page_html: str) -> str: 

6 # https://github.com/danburzo/percollate 

7 process: Process = await create_subprocess_exec( 

8 "percollate", 

9 *[ 

10 "html", 

11 "--output", 

12 "-", 

13 ], 

14 stdin=subprocess.PIPE, 

15 stdout=subprocess.PIPE, 

16 stderr=subprocess.DEVNULL, 

17 ) 

18 stdout, _ = await process.communicate(page_html.encode()) 

19 

20 return stdout.decode()