gcc-slycooper50 0.1.129__tar.gz → 0.1.130__tar.gz

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 gcc-slycooper50 might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gcc_slycooper50
3
- Version: 0.1.129
3
+ Version: 0.1.130
4
4
  Summary: Get it in.
5
5
  Author-email: sly cooper <slycooper50@gmail.com>
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "gcc_slycooper50"
7
- version = "0.1.129"
7
+ version = "0.1.130"
8
8
  authors = [
9
9
  { name="sly cooper", email="slycooper50@gmail.com" },
10
10
  ]
@@ -5,21 +5,45 @@ import json
5
5
  # Tree data
6
6
  # ---------------------------
7
7
  tree_data = {
8
- "Root": {"type": "root", "value": 10, "children": ["Child 1", "Child 2"]},
9
- "Child 1": {"type": "branch", "value": 5, "children": ["Grandchild 1.1"]},
8
+ "Root": {"type": "root", "value": 10, "children": ["Child 1", "Child 2", "Child 3"]},
9
+
10
+ "Child 1": {"type": "branch", "value": 5, "children": ["Grandchild 1.1", "Grandchild 1.2"]},
10
11
  "Child 2": {"type": "branch", "value": 7, "children": ["Grandchild 2.1", "Grandchild 2.2"]},
12
+ "Child 3": {"type": "branch", "value": 6, "children": ["Grandchild 3.1"]},
13
+
11
14
  "Grandchild 1.1": {"type": "leaf", "value": 3, "children": []},
12
- "Grandchild 2.1": {"type": "leaf", "value": 2, "children": [], "highlight": True}, # highlight in red
13
- "Grandchild 2.2": {"type": "leaf", "value": 4, "children": []}
15
+ "Grandchild 1.2": {"type": "leaf", "value": 4, "children": [], "highlight": True},
16
+
17
+ "Grandchild 2.1": {"type": "branch", "value": 2, "children": ["GreatGrandchild 2.1.1"]},
18
+ "Grandchild 2.2": {"type": "leaf", "value": 4, "children": []},
19
+
20
+ "Grandchild 3.1": {"type": "branch", "value": 5, "children": ["GreatGrandchild 3.1.1", "GreatGrandchild 3.1.2"]},
21
+
22
+ "GreatGrandchild 2.1.1": {"type": "leaf", "value": 1, "children": [], "highlight": True},
23
+ "GreatGrandchild 3.1.1": {"type": "leaf", "value": 2, "children": []},
24
+ "GreatGrandchild 3.1.2": {"type": "leaf", "value": 3, "children": [], "highlight": True},
14
25
  }
15
26
 
27
+ # ---------------------------
28
+ # Positions for layout (x,y)
29
+ # ---------------------------
16
30
  positions = {
17
31
  "Root": (0, 0),
18
- "Child 1": (-150, 150),
19
- "Child 2": (150, 150),
20
- "Grandchild 1.1": (-200, 300),
21
- "Grandchild 2.1": (100, 300),
22
- "Grandchild 2.2": (200, 300)
32
+ "Child 1": (-300, 150),
33
+ "Child 2": (0, 150),
34
+ "Child 3": (300, 150),
35
+
36
+ "Grandchild 1.1": (-400, 300),
37
+ "Grandchild 1.2": (-200, 300),
38
+
39
+ "Grandchild 2.1": (-50, 300),
40
+ "Grandchild 2.2": (50, 300),
41
+
42
+ "Grandchild 3.1": (300, 300),
43
+
44
+ "GreatGrandchild 2.1.1": (-50, 450),
45
+ "GreatGrandchild 3.1.1": (250, 450),
46
+ "GreatGrandchild 3.1.2": (350, 450),
23
47
  }
24
48
 
25
49
  colors = {"root": "#ffcc00", "branch": "#66ccff", "leaf": "#99ff99"}
@@ -27,21 +51,31 @@ colors = {"root": "#ffcc00", "branch": "#66ccff", "leaf": "#99ff99"}
27
51
  # ---------------------------
28
52
  # Build Pyvis Network
29
53
  # ---------------------------
30
- net = Network(height="600px", width="100%", directed=True)
31
- net.toggle_physics(True) # Enable physics for draggable nodes
54
+ #net = Network(height="600px", width="100%", directed=True, notebook=False)
55
+
56
+ net = Network(
57
+ height="600px",
58
+ width="100%",
59
+ directed=True,
60
+ notebook=False,
61
+ cdn_resources='remote' # <-- load JS via CDN, avoids utils.js errors
62
+ )
63
+ net.toggle_physics(False)
32
64
 
33
65
  for name, props in tree_data.items():
34
66
  x, y = positions[name]
35
- net.add_node(name, label=name, x=x, y=y, fixed=False, color=colors[props["type"]], size=25)
67
+ node_color = "red" if props.get("highlight") else colors[props["type"]]
68
+ net.add_node(name, label=name, x=x, y=y, fixed=False, color=node_color, size=25)
36
69
 
37
70
  for parent, props in tree_data.items():
38
71
  for child in props["children"]:
39
72
  net.add_edge(parent, child, arrows='to', smooth={'type': 'cubicBezier', 'roundness': 0.4})
40
73
 
74
+ # Generate HTML
41
75
  html = net.generate_html()
42
76
 
43
77
  # ---------------------------
44
- # Sidebar, expand menu, delete, save
78
+ # Extra sidebar JS/CSS
45
79
  # ---------------------------
46
80
  extra_js = f"""
47
81
  <style>
@@ -119,8 +153,30 @@ extra_js = f"""
119
153
  <script>
120
154
  var treeData = {json.dumps(tree_data)};
121
155
 
122
- // Click node → update sidebar
123
- network.on("click", function(params) {{
156
+ // Recursive red propagation
157
+ function updateRedness() {{
158
+ const redNodes = new Set();
159
+ function isRed(nodeId) {{
160
+ const node = treeData[nodeId];
161
+ if(node.children.length === 0) return !!node.highlight;
162
+ for(let c of node.children) {{
163
+ if(isRed(c)) return true;
164
+ }}
165
+ return false;
166
+ }}
167
+ for(let nodeId in treeData) {{
168
+ if(isRed(nodeId)) redNodes.add(nodeId);
169
+ }}
170
+ network.body.data.nodes.forEach(n => {{
171
+ let baseColor = (treeData[n.id].type === 'root') ? "#ffcc00" :
172
+ (treeData[n.id].type === 'branch') ? "#66ccff" : "#99ff99";
173
+ n.color = redNodes.has(n.id) ? "red" : baseColor;
174
+ }});
175
+ network.redraw();
176
+ }}
177
+
178
+ // Node click → sidebar
179
+ network.on("click", function(params){{
124
180
  hideExpandMenu();
125
181
  if(params.nodes.length > 0){{
126
182
  var nodeId = params.nodes[0];
@@ -138,37 +194,26 @@ network.on("click", function(params) {{
138
194
  // Menu actions
139
195
  function menuAction(action){{
140
196
  var nodeId = document.getElementById("menuBar").getAttribute("data-node");
141
- if(action === 'expand'){{
142
- showExpandMenu(treeData[nodeId]);
143
- }} else if(action === 'delete'){{
144
- deleteNode(nodeId);
145
- }} else {{
146
- alert(action + " action on node: " + nodeId);
147
- }}
197
+ if(action === 'expand') showExpandMenu(treeData[nodeId]);
198
+ else if(action === 'delete') deleteNode(nodeId);
199
+ else alert(action + " action on node: " + nodeId);
148
200
  }}
149
201
 
150
- // Expand button → show children
202
+ // Expand menu
151
203
  function showExpandMenu(node){{
152
204
  var menu = document.getElementById("expandMenu");
153
205
  menu.innerHTML = "";
154
-
155
206
  if(node.children.length === 0){{
156
207
  menu.innerHTML = "<div><i>No children</i></div>";
157
208
  }} else {{
158
209
  node.children.forEach(c => {{
159
210
  var item = document.createElement("div");
160
211
  item.textContent = c;
161
-
162
- // Highlight children in red if 'highlight' property is true
163
212
  if(treeData[c] && treeData[c].highlight){{
164
213
  item.style.color = "red";
165
214
  item.style.fontWeight = "bold";
166
215
  }}
167
-
168
- item.onclick = function(){{
169
- alert("Selected child: " + c);
170
- hideExpandMenu();
171
- }};
216
+ item.onclick = function(){{ alert("Selected child: " + c); hideExpandMenu(); }};
172
217
  menu.appendChild(item);
173
218
  }});
174
219
  }}
@@ -179,18 +224,13 @@ function showExpandMenu(node){{
179
224
  menu.style.display = "block";
180
225
  }}
181
226
 
182
- function hideExpandMenu(){{
183
- document.getElementById("expandMenu").style.display = "none";
184
- }}
185
-
227
+ function hideExpandMenu(){{ document.getElementById("expandMenu").style.display = "none"; }}
186
228
  window.addEventListener('click', function(e){{
187
229
  var menu = document.getElementById("expandMenu");
188
- if (!menu.contains(e.target) && e.target.id !== 'expandBtn') {{
189
- hideExpandMenu();
190
- }}
230
+ if(!menu.contains(e.target) && e.target.id !== 'expandBtn') hideExpandMenu();
191
231
  }});
192
232
 
193
- // Delete node from treeData and remove from graph
233
+ // Delete node
194
234
  function deleteNode(nodeId){{
195
235
  if(confirm("Delete node '" + nodeId + "'?")){{
196
236
  for(let key in treeData){{
@@ -202,10 +242,11 @@ function deleteNode(nodeId){{
202
242
  document.getElementById("nodeInfo").innerHTML = "<p><b>Click a node</b> to view details.</p>";
203
243
  document.getElementById("menuBar").style.display = "none";
204
244
  hideExpandMenu();
245
+ updateRedness();
205
246
  }}
206
247
  }}
207
248
 
208
- // Save tree to fixed file name
249
+ // Save tree
209
250
  function saveTree(){{
210
251
  const jsonData = JSON.stringify(treeData, null, 2);
211
252
  const blob = new Blob([jsonData], {{ type: "application/json" }});
@@ -218,6 +259,9 @@ function saveTree(){{
218
259
  document.body.removeChild(a);
219
260
  URL.revokeObjectURL(url);
220
261
  }}
262
+
263
+ // Initial red calculation
264
+ updateRedness();
221
265
  </script>
222
266
  """
223
267
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gcc_slycooper50
3
- Version: 0.1.129
3
+ Version: 0.1.130
4
4
  Summary: Get it in.
5
5
  Author-email: sly cooper <slycooper50@gmail.com>
6
6
  License-Expression: MIT
@@ -1,7 +1,6 @@
1
1
  LICENSE
2
2
  README.md
3
3
  pyproject.toml
4
- src/gcc_slycooper50/glad-2.0.8.tar.gz
5
4
  src/gcc_slycooper50/tree_app.py
6
5
  src/gcc_slycooper50.egg-info/PKG-INFO
7
6
  src/gcc_slycooper50.egg-info/SOURCES.txt