Coverage for phml\virtual_python\__init__.py: 100%
4 statements
« prev ^ index » next coverage.py v6.5.0, created at 2022-12-08 11:07 -0600
« prev ^ index » next coverage.py v6.5.0, created at 2022-12-08 11:07 -0600
1# pylint: skip-file
2'''Virtual Python
4This module serves to solve the problem of processing python
5in scopes and to evaluate python expressions.
7These expressions and scopes are python "blocks" that are injected
8into html which then creates my language phml.
10Here are examples of the python blocks:
121. Python element. This is treated as python files similarly to how
13`<script>` elements are treated as javascript files.
15```html
16<python>
17 from datetime import datetime
19 current_time = datetime.now().strftime('%H:%M:%S')
20</python>
21```
232. Inline python block. Mainly used for retreiving values
24or creating conditions. The local variables in the blocks are given
25from the python elements and from kwargs passed to the parser
27```html
28<p>{current_time}</p>
29```
313. Multiline python blocks. Same as inline python blocks just that they
32take up multiple lines. You can write more logic in these blocks, but
33there local variables are not retained. By default phml will return the last
34local variable similar to how Jupyter or the python in cli works.
36```html
37<p>
38 Hello, everyone my name is {firstname}. I
39 am a {work_position}.
40<p>
41<p>Here is a list of people and what they like</p>
42<p>
43 {
44 result = []
45 for i, person, like in enumerate(zip(people, likes)):
46 result.append(f"{i}. {person} likes {like}")
47 result = "\\n".join(result)
48 }
49</p>
50```
51'''
53from .import_objects import Import, ImportFrom
54from .vp import VirtualPython, get_vp_result, process_vp_blocks
56__all__ = ["VirtualPython", "get_vp_result", "process_vp_blocks", "Import", "ImportFrom"]