gcc-slycooper50 0.1.129__py3-none-any.whl → 0.1.131__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 gcc-slycooper50 might be problematic. Click here for more details.

@@ -0,0 +1,69 @@
1
+ window.addEventListener('load', () => {
2
+ const network = window.network;
3
+ const nodes = window.nodes;
4
+ const edges = window.edges;
5
+
6
+ const nodeList = document.getElementById("nodeList");
7
+ const nodeTitle = document.getElementById("nodeTitle");
8
+ const info = document.getElementById("info");
9
+ const save = document.getElementById("save_btt");
10
+
11
+ // Build adjacency map
12
+ const adjacency = {};
13
+ edges.get().forEach(e => {
14
+ if (!adjacency[e.from]) adjacency[e.from] = [];
15
+ adjacency[e.from].push(e.to);
16
+ });
17
+
18
+ // Update sidebar list with children of a node
19
+ function showChildren(nodeId) {
20
+ nodeList.innerHTML = "";
21
+ nodeTitle.textContent = "Children of " + nodeId;
22
+
23
+ const children = adjacency[nodeId] || [];
24
+ if (children.length === 0) {
25
+ const li = document.createElement("li");
26
+ li.textContent = "(no children)";
27
+ li.style.color = "#888";
28
+ nodeList.appendChild(li);
29
+ return;
30
+ }
31
+
32
+ children.forEach(childId => {
33
+ const li = document.createElement("li");
34
+ li.textContent = childId;
35
+ li.style.cursor = "pointer";
36
+ li.style.padding = "4px 0";
37
+ li.onmouseenter = () => li.style.color = "#ffcc00";
38
+ li.onmouseleave = () => li.style.color = "";
39
+ li.onclick = () => {
40
+ // Focus and highlight the clicked child
41
+ network.focus(childId, { scale: 1.5, animation: true });
42
+ nodes.update({ id: childId, color: "#ff4444" });
43
+ setTimeout(() => nodes.update({ id: childId, color: "#00ccff" }), 1500);
44
+ };
45
+ nodeList.appendChild(li);
46
+ });
47
+ }
48
+
49
+ // --- Event handlers ---
50
+ network.on("click", params => {
51
+ if (params.nodes.length > 0) {
52
+ const nodeId = params.nodes[0];
53
+ showChildren(nodeId);
54
+ }
55
+ });
56
+
57
+ network.on("hoverNode", params => {
58
+ info.textContent = "Hovering: " + params.node;
59
+ });
60
+
61
+ network.on("blurNode", () => {
62
+ info.textContent = "Click a node to see its children.";
63
+ });
64
+
65
+ save.addEventListener("click", () => {
66
+ console.log("SLYCOOPER");
67
+ });
68
+
69
+ });
@@ -1,228 +1,101 @@
1
1
  from pyvis.network import Network
2
- import json
3
-
4
- # ---------------------------
5
- # Tree data
6
- # ---------------------------
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"]},
10
- "Child 2": {"type": "branch", "value": 7, "children": ["Grandchild 2.1", "Grandchild 2.2"]},
11
- "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": []}
14
- }
15
-
16
- positions = {
17
- "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)
2
+ from pathlib import Path
3
+
4
+ # --- Create network ---
5
+ net = Network(height="100vh", width="100%", directed=True, bgcolor="#222222", font_color="white")
6
+
7
+ edges = [
8
+ ("Root", "Child1"),
9
+ ("Root", "Child2"),
10
+ ("Root", "Child3"),
11
+ ("Child1", "Sub1"),
12
+ ("Child1", "Sub2"),
13
+ ("Child2", "Sub3"),
14
+ ("Child3", "Sub4"),
15
+ ("Child3", "Sub5"),
16
+ ]
17
+
18
+ # Collect unique nodes
19
+ all_nodes = set([n for e in edges for n in e])
20
+ for n in all_nodes:
21
+ net.add_node(n, color="#00ccff" if n != "Root" else "#ffcc00")
22
+
23
+ for src, dst in edges:
24
+ net.add_edge(src, dst)
25
+
26
+ # Curvy edges + physics
27
+ net.set_options("""
28
+ {
29
+ "edges": {
30
+ "smooth": {
31
+ "type": "curvedCW",
32
+ "roundness": 0.3
33
+ }
34
+ },
35
+ "physics": {
36
+ "stabilization": false
37
+ }
23
38
  }
24
-
25
- colors = {"root": "#ffcc00", "branch": "#66ccff", "leaf": "#99ff99"}
26
-
27
- # ---------------------------
28
- # Build Pyvis Network
29
- # ---------------------------
30
- net = Network(height="600px", width="100%", directed=True)
31
- net.toggle_physics(True) # Enable physics for draggable nodes
32
-
33
- for name, props in tree_data.items():
34
- x, y = positions[name]
35
- net.add_node(name, label=name, x=x, y=y, fixed=False, color=colors[props["type"]], size=25)
36
-
37
- for parent, props in tree_data.items():
38
- for child in props["children"]:
39
- net.add_edge(parent, child, arrows='to', smooth={'type': 'cubicBezier', 'roundness': 0.4})
40
-
41
- html = net.generate_html()
42
-
43
- # ---------------------------
44
- # Sidebar, expand menu, delete, save
45
- # ---------------------------
46
- extra_js = f"""
47
- <style>
48
- #sidebar {{
49
- position: absolute;
50
- left: 10px;
51
- top: 10px;
52
- width: 250px;
53
- background: #f8f8f8;
54
- padding: 10px;
55
- border-radius: 10px;
56
- box-shadow: 0 0 8px rgba(0,0,0,0.2);
57
- font-family: Arial;
58
- }}
59
- #menuBar button {{
60
- margin: 3px;
61
- padding: 5px 8px;
62
- border: none;
63
- background: #ddd;
64
- border-radius: 4px;
65
- cursor: pointer;
66
- }}
67
- #menuBar button:hover {{
68
- background: #ccc;
69
- }}
70
- #expandMenu {{
71
- display: none;
72
- position: absolute;
73
- background: white;
74
- border: 1px solid #aaa;
75
- box-shadow: 0 0 5px rgba(0,0,0,0.2);
76
- border-radius: 5px;
77
- padding: 5px;
78
- margin-top: 5px;
79
- z-index: 1000;
80
- }}
81
- #expandMenu div {{
82
- padding: 5px;
83
- cursor: pointer;
84
- }}
85
- #expandMenu div:hover {{
86
- background: #eee;
87
- }}
88
- #saveButton {{
89
- width: 100%;
90
- margin-top: 10px;
91
- padding: 8px;
92
- border: none;
93
- background: #4CAF50;
94
- color: white;
95
- font-weight: bold;
96
- border-radius: 6px;
97
- cursor: pointer;
98
- }}
99
- #saveButton:hover {{
100
- background: #45a049;
101
- }}
102
- </style>
103
-
104
- <div id="sidebar">
105
- <h3 style="text-align:center;">Node Details</h3>
106
- <div id="nodeInfo">
107
- <p><b>Click a node</b> to view details.</p>
108
- </div>
109
- <hr>
110
- <div id="menuBar" style="display:none; text-align:center;">
111
- <button onclick="menuAction('edit')">✏️ Edit</button>
112
- <button onclick="menuAction('delete')">🗑️ Delete</button>
113
- <button id="expandBtn" onclick="menuAction('expand')">🔽 Expand</button>
39
+ """)
40
+
41
+ # Save base template
42
+ net.save_graph("template.html")
43
+
44
+ # --- Inject sidebar and JS ---
45
+ with open("template.html", "r") as f:
46
+ html = f.read()
47
+
48
+ sidebar_html = """
49
+ <div id="sidebar" style="
50
+ position: fixed;
51
+ left: 10px;
52
+ top: 10px;
53
+ width: 240px;
54
+ height: 95vh;
55
+ background: #2c2c2c;
56
+ color: white;
57
+ padding: 12px;
58
+ border-radius: 8px;
59
+ font-family: sans-serif;
60
+ display: flex;
61
+ flex-direction: column;
62
+ box-shadow: 0 0 10px rgba(0,0,0,0.4);
63
+ ">
64
+ <h3 style="margin-top: 0;">Graph Controls</h3>
65
+
66
+ <hr style="border: 0; border-top: 1px solid #555; margin: 8px 0;">
67
+ <h4 id="nodeTitle" style="margin: 4px 0;">Children</h4>
68
+ <div id="nodeContainer" style="
69
+ flex: 1;
70
+ overflow-y: auto;
71
+ border: 1px solid #555;
72
+ border-radius: 6px;
73
+ background: #1e1e1e;
74
+ padding: 6px;
75
+ scrollbar-width: thin;
76
+ scrollbar-color: #666 #2c2c2c;
77
+ ">
78
+ <ul id="nodeList" style="
79
+ list-style: none;
80
+ padding-left: 0;
81
+ margin: 0;
82
+ "></ul>
114
83
  </div>
115
- <div id="expandMenu"></div>
116
- <button id="saveButton" onclick="saveTree()">💾 Save Tree</button>
117
- </div>
118
-
119
- <script>
120
- var treeData = {json.dumps(tree_data)};
121
-
122
- // Click node → update sidebar
123
- network.on("click", function(params) {{
124
- hideExpandMenu();
125
- if(params.nodes.length > 0){{
126
- var nodeId = params.nodes[0];
127
- var node = treeData[nodeId];
128
- document.getElementById("nodeInfo").innerHTML =
129
- "<p><b>Name:</b> " + nodeId + "</p>" +
130
- "<p><b>Type:</b> " + node.type + "</p>" +
131
- "<p><b>Value:</b> " + node.value + "</p>" +
132
- "<p><b>Children:</b> " + (node.children.join(", ") || "None") + "</p>";
133
- document.getElementById("menuBar").style.display = "block";
134
- document.getElementById("menuBar").setAttribute("data-node", nodeId);
135
- }}
136
- }});
137
-
138
- // Menu actions
139
- function menuAction(action){{
140
- 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
- }}
148
- }}
149
-
150
- // Expand button → show children
151
- function showExpandMenu(node){{
152
- var menu = document.getElementById("expandMenu");
153
- menu.innerHTML = "";
154
-
155
- if(node.children.length === 0){{
156
- menu.innerHTML = "<div><i>No children</i></div>";
157
- }} else {{
158
- node.children.forEach(c => {{
159
- var item = document.createElement("div");
160
- item.textContent = c;
161
84
 
162
- // Highlight children in red if 'highlight' property is true
163
- if(treeData[c] && treeData[c].highlight){{
164
- item.style.color = "red";
165
- item.style.fontWeight = "bold";
166
- }}
85
+ <hr style="border: 0; border-top: 1px solid #555; margin: 8px 0;">
86
+ <p id="info" style="font-size: 14px; color: #ccc;">Click a node to see its children.</p>
167
87
 
168
- item.onclick = function(){{
169
- alert("Selected child: " + c);
170
- hideExpandMenu();
171
- }};
172
- menu.appendChild(item);
173
- }});
174
- }}
175
- var expandBtn = document.getElementById("expandBtn");
176
- var rect = expandBtn.getBoundingClientRect();
177
- menu.style.left = rect.left + "px";
178
- menu.style.top = (rect.bottom + window.scrollY) + "px";
179
- menu.style.display = "block";
180
- }}
181
-
182
- function hideExpandMenu(){{
183
- document.getElementById("expandMenu").style.display = "none";
184
- }}
185
-
186
- window.addEventListener('click', function(e){{
187
- var menu = document.getElementById("expandMenu");
188
- if (!menu.contains(e.target) && e.target.id !== 'expandBtn') {{
189
- hideExpandMenu();
190
- }}
191
- }});
192
-
193
- // Delete node from treeData and remove from graph
194
- function deleteNode(nodeId){{
195
- if(confirm("Delete node '" + nodeId + "'?")){{
196
- for(let key in treeData){{
197
- let idx = treeData[key].children.indexOf(nodeId);
198
- if(idx !== -1) treeData[key].children.splice(idx, 1);
199
- }}
200
- delete treeData[nodeId];
201
- network.body.data.nodes.remove({{id: nodeId}});
202
- document.getElementById("nodeInfo").innerHTML = "<p><b>Click a node</b> to view details.</p>";
203
- document.getElementById("menuBar").style.display = "none";
204
- hideExpandMenu();
205
- }}
206
- }}
88
+ <div style="display: flex; gap: 10px; margin-bottom: 12px;">
89
+ <button id="del_node">Delete Node</button>
90
+ </div>
207
91
 
208
- // Save tree to fixed file name
209
- function saveTree(){{
210
- const jsonData = JSON.stringify(treeData, null, 2);
211
- const blob = new Blob([jsonData], {{ type: "application/json" }});
212
- const url = URL.createObjectURL(blob);
213
- const a = document.createElement("a");
214
- a.href = url;
215
- a.download = "tree_data.json";
216
- document.body.appendChild(a);
217
- a.click();
218
- document.body.removeChild(a);
219
- URL.revokeObjectURL(url);
220
- }}
221
- </script>
92
+ <button id="save_btt">Save New Connections</button>
93
+ </div>
222
94
  """
223
95
 
224
- with open("tree.html", "w") as f:
225
- f.write(html.replace("</body>", extra_js + "</body>"))
96
+ html = html.replace("</body>", f"{sidebar_html}\n<script src={str(Path(__file__).resolve().parent)+"/"+"extra.js"}></script>\n</body>")
226
97
 
227
- print("✅ Open tree.html in your browser")
98
+ with open("index.html", "w") as f:
99
+ f.write(html)
228
100
 
101
+ print("✅ Created index.html with child-list sidebar.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gcc_slycooper50
3
- Version: 0.1.129
3
+ Version: 0.1.131
4
4
  Summary: Get it in.
5
5
  Author-email: sly cooper <slycooper50@gmail.com>
6
6
  License-Expression: MIT
@@ -0,0 +1,7 @@
1
+ gcc_slycooper50/extra.js,sha256=I0EYNY40uJMxWlH8LpM_DdJMZyX6Ym9y2RsnqaY-Xas,2017
2
+ gcc_slycooper50/tree_app.py,sha256=7tCKw_2rTBpQvwQm4CmcoAS1JAF8E4ggUsKsXOSFo-4,2395
3
+ gcc_slycooper50-0.1.131.dist-info/licenses/LICENSE,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
4
+ gcc_slycooper50-0.1.131.dist-info/METADATA,sha256=oCJtS-IntJBPOc8PZJxtbD5LKQ-ZblC6RhvhwmdMBoQ,356
5
+ gcc_slycooper50-0.1.131.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ gcc_slycooper50-0.1.131.dist-info/top_level.txt,sha256=yDxkl8ek8lYZRCxgy1mWsk0qEPq8BBIkw_EQIlq5_q8,16
7
+ gcc_slycooper50-0.1.131.dist-info/RECORD,,
Binary file
@@ -1,7 +0,0 @@
1
- gcc_slycooper50/glad-2.0.8.tar.gz,sha256=RPBvkZVCfHAX9QKNCJT1frIWsKj3xO2nzog3Mq6y0Pw,645593
2
- gcc_slycooper50/tree_app.py,sha256=6y3YKz3Pl0LhiouDrLCREOIZP1nLdIboIA09TCPqrgc,6778
3
- gcc_slycooper50-0.1.129.dist-info/licenses/LICENSE,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
4
- gcc_slycooper50-0.1.129.dist-info/METADATA,sha256=2hTRw9ilrurpBEh7sBVoCSgy_Sz9w2PtxKQuFpIH654,356
5
- gcc_slycooper50-0.1.129.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
- gcc_slycooper50-0.1.129.dist-info/top_level.txt,sha256=yDxkl8ek8lYZRCxgy1mWsk0qEPq8BBIkw_EQIlq5_q8,16
7
- gcc_slycooper50-0.1.129.dist-info/RECORD,,