pyview-web 0.0.23__py3-none-any.whl → 0.0.25__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pyview-web might be problematic. Click here for more details.

@@ -11,19 +11,24 @@ def calc_diff(old_tree: dict[str, Any], new_tree: dict[str, Any]) -> dict[str, A
11
11
  and "s" in new_tree[key]
12
12
  and "d" in new_tree[key]
13
13
  ):
14
+ if isinstance(old_tree[key], str):
15
+ diff[key] = new_tree[key]
16
+ continue
17
+
14
18
  # Handle special case of for loop
19
+ old_static = old_tree[key].get("s", [])
20
+ new_static = new_tree[key]["s"]
21
+
15
22
  old_dynamic = old_tree[key]["d"]
16
23
  new_dynamic = new_tree[key]["d"]
17
24
 
18
- old_static = old_tree[key]["s"]
19
- new_static = new_tree[key]["s"]
20
-
21
25
  if old_static != new_static:
22
26
  diff[key] = {"s": new_static, "d": new_dynamic}
23
27
  continue
24
28
 
25
29
  if old_dynamic != new_dynamic:
26
30
  diff[key] = {"d": new_dynamic}
31
+
27
32
  elif isinstance(new_tree[key], dict):
28
33
  nested_diff = calc_diff(old_tree[key], new_tree[key])
29
34
  if nested_diff:
@@ -11,10 +11,14 @@ class PartsComprehension:
11
11
  def __init__(self, parts: list[Part]):
12
12
  self.parts = parts
13
13
 
14
- def render_parts(self) -> dict[str, Any]:
14
+ def render_parts(self) -> Union[dict[str, Any], str]:
15
15
  if len(self.parts) == 0:
16
16
  return ""
17
17
 
18
+ if len(self.parts) == 1:
19
+ if isinstance(self.parts[0], PartsTree) and self.parts[0].is_empty():
20
+ return ""
21
+
18
22
  def render(p: Part) -> Any:
19
23
  if isinstance(p, str):
20
24
  return p
@@ -38,17 +42,13 @@ class PartsTree:
38
42
  self.statics.append(s)
39
43
 
40
44
  def add_dynamic(self, d: Union[Part, list[Part]]):
41
-
42
45
  if len(self.statics) < len(self.dynamics) + 1:
43
46
  self.statics.append("")
44
47
 
45
48
  if isinstance(d, str):
46
49
  self.dynamics.append(d)
47
50
  elif isinstance(d, list):
48
- if len(d) > 1:
49
- self.dynamics.append(PartsComprehension(d))
50
- elif len(d) == 1:
51
- self.dynamics.append(d[0].flatten())
51
+ self.dynamics.append(PartsComprehension(d))
52
52
  else:
53
53
  self.dynamics.append(d.flatten())
54
54
 
@@ -85,3 +85,8 @@ class PartsTree:
85
85
  resp[f"{i}"] = dynamic.render_parts()
86
86
 
87
87
  return resp
88
+
89
+ def is_empty(self) -> bool:
90
+ return len(self.dynamics) == 0 and (
91
+ len(self.statics) == 0 or (len(self.statics) == 1 and self.statics[0] == "")
92
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyview-web
3
- Version: 0.0.23
3
+ Version: 0.0.25
4
4
  Summary: LiveView in Python
5
5
  Home-page: https://pyview.rocks
6
6
  License: MIT
@@ -20,7 +20,7 @@ pyview/session.py,sha256=nC8ExyVwfCgQfx9T-aJGyFhr2C7jsrEY_QFkaXtP28U,432
20
20
  pyview/static/assets/app.js,sha256=QoXfdcOCYwVYJftvjsIIVwFye7onaOJMxRpalyYqoMU,200029
21
21
  pyview/template/__init__.py,sha256=c5hLRfsF2fDOz8aOsoOgoCeBV6VBzdqN_Ktg3mYPw8A,509
22
22
  pyview/template/live_template.py,sha256=wSKyBw7ejpUY5qXUZdE36Jeeix8Of0CUq8eZdQwxXyg,1864
23
- pyview/template/render_diff.py,sha256=UpmxQZ-ImDqEUIehcoLfpdClRVYV5StTOP9iKsU8AZ0,1090
23
+ pyview/template/render_diff.py,sha256=v7EVmn8oJdh809N0vnSLK8OiDs1BOpErF36y4VUo9ew,1214
24
24
  pyview/template/root_template.py,sha256=zCUs1bt8R7qynhBE0tTSEYfdkGtbeKNmPhwzRiFNdsI,2031
25
25
  pyview/template/serializer.py,sha256=WDZfqJr2LMlf36fUW2CmWc2aREc63553_y_GRP2-qYc,826
26
26
  pyview/template/utils.py,sha256=S8593UjUJztUrtC3h1EL9MxQp5uH7rFDTNkv9C6A_xU,642
@@ -37,10 +37,10 @@ pyview/vendor/ibis/filters.py,sha256=M36KS6dlzfsb2NmHkbVuo8gJbiQ6aQjcHzXxHwZ3Afw
37
37
  pyview/vendor/ibis/loaders.py,sha256=NYW7_hlC7TRPDau37bgiOCsvsBgIPpUEpb1NbroUVUA,3457
38
38
  pyview/vendor/ibis/nodes.py,sha256=TgFt4q5MrVW3gC3PVitrs2LyXKllRveooM7XKydNATk,25617
39
39
  pyview/vendor/ibis/template.py,sha256=IX9z-Ig13yJyRnMqtB52eiRLe002qdIxnfa7fYEXLqM,2314
40
- pyview/vendor/ibis/tree.py,sha256=5LAjl3q9iPMZBb6QbKurWj9-QGKLVf11K2_bQotWlUc,2293
40
+ pyview/vendor/ibis/tree.py,sha256=hg8f-fKHeo6DE8R-QgAhdvEaZ8rKyz7p0nGwPy0CBTs,2509
41
41
  pyview/vendor/ibis/utils.py,sha256=nLSaxPR9vMphzV9qinlz_Iurv9c49Ps6Knv8vyNlewU,2768
42
42
  pyview/ws_handler.py,sha256=Vi5aIoxz_Z9qOEcA5fgxsSoJtLz7n_ytbJ8vZiWDvGc,8473
43
- pyview_web-0.0.23.dist-info/LICENSE,sha256=M_bADaBm9_MV9llX3lCicksLhwk3eZUjA2srE0uUWr0,1071
44
- pyview_web-0.0.23.dist-info/METADATA,sha256=YtPgnrwK0Au_IByrW0cnTD9RX1U5Dicxy76S8Ax92Fs,5276
45
- pyview_web-0.0.23.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
46
- pyview_web-0.0.23.dist-info/RECORD,,
43
+ pyview_web-0.0.25.dist-info/LICENSE,sha256=M_bADaBm9_MV9llX3lCicksLhwk3eZUjA2srE0uUWr0,1071
44
+ pyview_web-0.0.25.dist-info/METADATA,sha256=-UhlfnbHQaDx-Elu2KFZRxrV2brUwuJ2GAwFfrRWRGU,5276
45
+ pyview_web-0.0.25.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
46
+ pyview_web-0.0.25.dist-info/RECORD,,