Coverage for src/lcdoc/mkdocs/lp/plugs/python/__init__.py: 92.34%
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
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
1"""
2### `python`
4This runs the block within a python session.
6All context available in the `ctx` dicts.
8Result will be what is printed on stdout.
10Decide via the language argument (```<language> lp mode=python) what formatting should be applied.
11"""
13import importlib lp|index.md
15from importlib import import_module lp|index.md
16from io import StringIO lp|index.md
17from pprint import pformat lp|index.md
19from lcdoc import lp lp|index.md
20from lcdoc.tools import app, deep_update, dirname, project, read_file, write_file lp|index.md
23multi_line_to_list = False lp|index.md
24fmt_default = 'unset' lp|index.md
26sessions = S = {} lp|index.md
28config = lambda: Session.kw['LP'].config lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|index.mdlp|index.md
29page = lambda: Session.kw['LP'].page 29 ↛ exitline 29 didn't run the lambda on line 29lp|index.md
30lpkw = lambda: Session.kw lp|about/changelog.mdlp|features/lp/python/call_flow_logging/index.mdlp|index.mdlp|index.md
31stats = lambda: page().stats 31 ↛ exitline 31 didn't run the lambda on line 31lp|index.md
34def new_session_ctx(): lp|index.md
35 return {'out': [], 'locals': {}, 'assets': {}} lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/python/call_flow_logging/index.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
38class Session(lp.SessionNS): lp|index.md
44 def delete(cls, ns, kw):
45 sessions.pop(ns, 0) lp|features/lp/python/_tech.md
48 def pre(cls, session_name, kw):
49 Session.name, Session.kw = session_name, kw lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/python/call_flow_logging/index.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
50 Session.cur = sessions.setdefault(session_name, new_session_ctx()) lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/python/call_flow_logging/index.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
51 # we support pre param to run system stuff before python
52 lp.SessionNS.pre(session_name, kw) lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/python/call_flow_logging/index.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
55 def post(cls, session_name, kw):
56 Session.cur['out'].clear() lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
57 if cls.name is None: lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
58 Session.cur['locals'].clear() lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
59 sessions.pop(None) # forget it, no name was given lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
60 # we support post param to run system stuff before python
61 lp.SessionNS.post(session_name, kw) lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
64def out(s, t=None, innerkw=None): lp|index.md
65 Session.cur['out'].append([t, s, innerkw]) lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
68def printed(s, **innerkw): lp|index.md
69 out(s, 'printed', innerkw=innerkw) lp|features/lp/plugs/flowchart/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.md
72def show(s, **innerkw): lp|index.md
73 f = matching_pyplug(s, innerkw) lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/call_flow_logging/index.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
74 if f: lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/call_flow_logging/index.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
75 s = f(s, **innerkw) lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/python/call_flow_logging/index.mdlp|index.md
76 # need this for call_flow_logging :-/
77 # if isinstance(s, dict):
78 # if 'nocache' in s:
79 # lpkw()['nocache'] = s['nocache']
80 # s = s['res']
81 out(s, 'md', innerkw=innerkw) lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
84# keys: matching strings on s and s class, with s the argument of `show()`:
89def matching_pyplug(s, innerkw): lp|index.md
90 """find rendering pyplug based on type of output"""
91 if innerkw.get('md'): lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/call_flow_logging/index.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
92 return # markdown was forced (show('> foo', md=True) lp|index.md
93 if isinstance(s, str) and s in fmts: lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/call_flow_logging/index.mdlp|features/lp/syntax.mdlp|index.md
94 return fmts[s] lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/python/call_flow_logging/index.mdlp|index.md
95 for k in fmts: lp|features/lp/plugs/lightbox/index.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.md
96 if callable(k): lp|features/lp/plugs/lightbox/index.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.md
97 r = k(s, innerkw) lp|features/lp/plugs/lightbox/index.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.md
98 if r: lp|features/lp/plugs/lightbox/index.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.md
99 return fmts[k] lp|features/lp/plugs/lightbox/index.md
100 elif k in str([s, s.__class__]): 100 ↛ 101line 100 didn't jump to line 101, because the condition on line 100 was never truelp|features/lp/plugs/lightbox/index.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.md
101 return fmts[k]
102 if not isinstance(s, str): 102 ↛ 103line 102 didn't jump to line 103, because the condition on line 102 was never truelp|features/lp/python/_tech.mdlp|features/lp/syntax.md
103 app.die('No formatter matched', s=s, **innerkw)
106def fmt(t, s, kw): lp|index.md
107 if t == 'md': lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
108 o = (False, s) lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
109 elif isinstance(s, str): lp|features/lp/plugs/flowchart/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.md
110 o = (True, s) lp|features/lp/plugs/flowchart/index.mdlp|features/lp/python/_tech.md
111 else:
112 o = (True, pformat(s)) lp|features/lp/python/_tech.md
113 return o lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
116D_lp_py = lambda: project.root() + '/build/autodocs/lp_python/' lp|features/lp/python/call_flow_logging/index.mdlp|index.md
119def cmd_to_module_file(cmd, kw): lp|index.md
120 dr = D_lp_py() lp|features/lp/python/call_flow_logging/index.md
121 fn = dr + dirname(kw['LP'].page.file.src_path) + '/%(id)s.py' % kw lp|features/lp/python/call_flow_logging/index.md
122 h = 'from lcdoc.mkdocs.lp.plugs import python' lp|features/lp/python/call_flow_logging/index.md
123 h += '\nprint = python.printed' lp|features/lp/python/call_flow_logging/index.md
124 h += '\nshow = python.show' lp|features/lp/python/call_flow_logging/index.md
125 h += '\ndef run_lp_flow():' lp|features/lp/python/call_flow_logging/index.md
126 cmd = ('\n' + cmd).replace('\n', '\n ') lp|features/lp/python/call_flow_logging/index.md
127 write_file(fn, h + '\n' + cmd, mkdir=1) lp|features/lp/python/call_flow_logging/index.md
128 sys.path.insert(0, dirname(fn)) if not dirname(fn) in sys.path else 0 lp|features/lp/python/call_flow_logging/index.md
129 return fn lp|features/lp/python/call_flow_logging/index.md
132def build_res(plug_res): lp|index.md
133 m = {'res': ''} lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
134 for r in plug_res: lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
135 if isinstance(r, str): lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
136 m['res'] += '\n\n' + r lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
137 elif isinstance(r, dict): lp|features/lp/plugs/lightbox/index.mdlp|features/lp/python/_tech.mdlp|index.md
138 for k, v in r.items(): lp|features/lp/plugs/lightbox/index.mdlp|index.md
139 vh = m.get(k) lp|features/lp/plugs/lightbox/index.mdlp|index.md
140 if vh == None: lp|features/lp/plugs/lightbox/index.mdlp|index.md
141 m[k] = v lp|features/lp/plugs/lightbox/index.mdlp|index.md
142 elif isinstance(vh, str): 142 ↛ 144line 142 didn't jump to line 144, because the condition on line 142 was never falselp|features/lp/plugs/lightbox/index.mdlp|index.md
143 m[k] += vh + '\n\n' + v lp|features/lp/plugs/lightbox/index.mdlp|index.md
144 elif isinstance(vh, dict):
145 deep_update(vh, v)
146 elif r is None: 146 ↛ 149line 146 didn't jump to line 149, because the condition on line 146 was never falselp|features/lp/python/_tech.md
147 pass lp|features/lp/python/_tech.md
148 else:
149 app.die('Not supported result type', res=r)
150 return m lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
153def run(cmd, kw): lp|index.md
154 """
155 interpret the command as python
156 """
157 l = kw['mode'].split(':') lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/python/call_flow_logging/index.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
158 # set if not yet done:
159 project.root(kw['LP'].config) lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/python/call_flow_logging/index.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
160 plug_res = [''] lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/python/call_flow_logging/index.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
162 def add(r): lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/python/call_flow_logging/index.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
163 plug_res.append(r) lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
165 if len(l) > 1 and l[1] in fmts: 165 ↛ 166line 165 didn't jump to line 166, because the condition on line 165 was never truelp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/python/call_flow_logging/index.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
166 add(fmts[l[1]](l[1], **kw))
167 else:
168 # short form convenience: `lp:python show=project_dependencies`
169 shw = kw.pop('show', '') lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/python/call_flow_logging/index.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
170 if shw and isinstance(cmd, str): lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/python/call_flow_logging/index.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
171 cmd = 'show("%s")' % shw + cmd lp|about/changelog.mdlp|about/credits.mdlp|index.md
172 if kw.get('cfl'): lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/python/call_flow_logging/index.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
173 modfn = cmd_to_module_file(cmd, kw) lp|features/lp/python/call_flow_logging/index.md
174 m = importlib.import_module(kw['id']) lp|features/lp/python/call_flow_logging/index.md
175 m.run_lp_flow() lp|features/lp/python/call_flow_logging/index.md
176 else:
177 loc = Session.cur['locals'] lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
178 g = {'print': printed, 'show': show, 'ctx': kw} lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
179 loc.update(g) lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
180 exec(cmd, loc) lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
181 o = Session.cur['out'] lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
182 res = [fmt(*i) for i in o] lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
183 fncd = False lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
184 # if the fmt is given (mk_console usually), then we show the command (python code)
185 # and the output within the usual lp fenced code block.
186 # if it was unset then we open and close fenced code only for print outs
187 fstart, fstop = (None, None) lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
188 if kw['fmt'] == 'unset': lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
189 fstart = '```python' lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
190 fstop = '```' lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
191 while res: lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
192 is_fenced, o = res.pop(0) lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
193 if is_fenced and not fncd: lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
194 add(fstart) lp|features/lp/plugs/flowchart/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.md
195 fncd = True lp|features/lp/plugs/flowchart/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.md
196 elif not is_fenced and fncd: lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
197 add(fstop) lp|features/lp/python/_tech.md
198 fncd = False lp|features/lp/python/_tech.md
199 add(o) lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
200 if fncd: lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
201 add(fstop) lp|features/lp/plugs/flowchart/index.mdlp|features/lp/python/_tech.md
202 r = build_res(plug_res) lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
203 # python code may explicitly set a result as object, ready to process e.g. in a mode pipe
204 rslt = Session.cur['locals'].get('result') lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
205 if rslt: lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
206 r['result'] = rslt lp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.md
207 # was fmt given by user?
208 if kw['fmt'] == 'unset': lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
209 r['formatted'] = True lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
210 if 'nocache' in kw: 210 ↛ 211line 210 didn't jump to line 211, because the condition on line 210 was never truelp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
211 r['nocache'] = kw['nocache']
212 r.update(Session.cur['assets']) lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
213 return r lp|about/changelog.mdlp|about/coverage.mdlp|about/credits.mdlp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/flowchart/index.mdlp|features/lp/plugs/lightbox/index.mdlp|features/lp/plugs/markmap/index.mdlp|features/lp/python/_tech.mdlp|features/lp/python/_tech.mdlp|features/lp/syntax.mdlp|index.mdlp|index.md
216def import_pyplugs(frm): lp|index.md
217 m = import_module(frm) lp|index.md
218 for k in [i for i in dir(m) if not i.startswith('_')]: lp|index.md
219 v = getattr(m, k) lp|index.md
220 if hasattr(v, 'register'): 220 ↛ 218line 220 didn't jump to line 218, because the condition on line 220 was never falselp|index.md
221 if callable(v.register): lp|index.md
222 v.register(fmts) lp|index.md
223 else:
224 fmts.update(v.register) lp|index.md
227import_pyplugs('lcdoc.mkdocs.lp.plugs.python.pyplugs') lp|index.md
229 import_pyplugs('lp_python_plugins') # allow customs lp|index.md