Coverage for src/lcdoc/mkdocs/lp/plugs/python/pyplugs/lprunner/__init__.py: 52.38%

Shortcuts on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

19 statements  

1import os lp|index.md

2from functools import partial lp|index.md

3 

4from lcdoc.const import lprunner_sep as sep lp|index.md

5from lcdoc.mkdocs.lp.plugs import python lp|index.md

6from lcdoc.mkdocs.tools import make_img lp|index.md

7from lcdoc.tools import write_file lp|index.md

8 

9config, page, Session = (python.config, python.page, python.Session) lp|index.md

10 

11 

12def register(fmts): lp|index.md

13 """registering us as renderer for show(<pyplot module>) within lp python""" 

14 fmts['lprunner'] = lprunner lp|index.md

15 

16 

17msg = ''' 

18??? "Run this locally" 

19  

20 You can run the code on this page locally via: 

21 

22 ```bash 

23 pip install --user docutools # if not yet installed 

24 mdrun "%s" 

25 ``` 

26''' 

27 

28 

29def lprunner(s, **kw): lp|index.md

30 """The client requires the source""" 

31 url = config()['site_dir'] + '/' + page().url 

32 if not url.endswith('/'): 

33 python.app.die('for runners we require URLs ending with "/"') 

34 url += 'runner.md' 

35 src = page().markdown 

36 write_file(url, src, mkdir=True) 

37 url = config()['site_url'] + page().url 

38 return {'res': msg % url, 'formatted': True, 'nocache': True}