gcc-slycooper50 0.1.130__tar.gz → 0.1.131__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.130
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "gcc_slycooper50"
7
- version = "0.1.130"
7
+ version = "0.1.131"
8
8
  authors = [
9
9
  { name="sly cooper", email="slycooper50@gmail.com" },
10
10
  ]
@@ -22,4 +22,4 @@ license-files = ["LICEN[CS]E*"]
22
22
  where = ["src"]
23
23
 
24
24
  [tool.setuptools.package-data]
25
- "*" = ['*.tar.gz', '*.tar.xz', '*.zip', '*.tar', '*.tar.bz2']
25
+ "*" = ['*.tar.gz', '*.tar.xz', '*.zip', '*.tar', '*.tar.bz2', '*.js']
@@ -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
+ });
@@ -0,0 +1,101 @@
1
+ from pyvis.network import Network
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
+ }
38
+ }
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>
83
+ </div>
84
+
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>
87
+
88
+ <div style="display: flex; gap: 10px; margin-bottom: 12px;">
89
+ <button id="del_node">Delete Node</button>
90
+ </div>
91
+
92
+ <button id="save_btt">Save New Connections</button>
93
+ </div>
94
+ """
95
+
96
+ html = html.replace("</body>", f"{sidebar_html}\n<script src={str(Path(__file__).resolve().parent)+"/"+"extra.js"}></script>\n</body>")
97
+
98
+ with open("index.html", "w") as f:
99
+ f.write(html)
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.130
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
@@ -1,6 +1,7 @@
1
1
  LICENSE
2
2
  README.md
3
3
  pyproject.toml
4
+ src/gcc_slycooper50/extra.js
4
5
  src/gcc_slycooper50/tree_app.py
5
6
  src/gcc_slycooper50.egg-info/PKG-INFO
6
7
  src/gcc_slycooper50.egg-info/SOURCES.txt
@@ -1,272 +0,0 @@
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", "Child 3"]},
9
-
10
- "Child 1": {"type": "branch", "value": 5, "children": ["Grandchild 1.1", "Grandchild 1.2"]},
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
-
14
- "Grandchild 1.1": {"type": "leaf", "value": 3, "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},
25
- }
26
-
27
- # ---------------------------
28
- # Positions for layout (x,y)
29
- # ---------------------------
30
- positions = {
31
- "Root": (0, 0),
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),
47
- }
48
-
49
- colors = {"root": "#ffcc00", "branch": "#66ccff", "leaf": "#99ff99"}
50
-
51
- # ---------------------------
52
- # Build Pyvis Network
53
- # ---------------------------
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)
64
-
65
- for name, props in tree_data.items():
66
- x, y = positions[name]
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)
69
-
70
- for parent, props in tree_data.items():
71
- for child in props["children"]:
72
- net.add_edge(parent, child, arrows='to', smooth={'type': 'cubicBezier', 'roundness': 0.4})
73
-
74
- # Generate HTML
75
- html = net.generate_html()
76
-
77
- # ---------------------------
78
- # Extra sidebar JS/CSS
79
- # ---------------------------
80
- extra_js = f"""
81
- <style>
82
- #sidebar {{
83
- position: absolute;
84
- left: 10px;
85
- top: 10px;
86
- width: 250px;
87
- background: #f8f8f8;
88
- padding: 10px;
89
- border-radius: 10px;
90
- box-shadow: 0 0 8px rgba(0,0,0,0.2);
91
- font-family: Arial;
92
- }}
93
- #menuBar button {{
94
- margin: 3px;
95
- padding: 5px 8px;
96
- border: none;
97
- background: #ddd;
98
- border-radius: 4px;
99
- cursor: pointer;
100
- }}
101
- #menuBar button:hover {{
102
- background: #ccc;
103
- }}
104
- #expandMenu {{
105
- display: none;
106
- position: absolute;
107
- background: white;
108
- border: 1px solid #aaa;
109
- box-shadow: 0 0 5px rgba(0,0,0,0.2);
110
- border-radius: 5px;
111
- padding: 5px;
112
- margin-top: 5px;
113
- z-index: 1000;
114
- }}
115
- #expandMenu div {{
116
- padding: 5px;
117
- cursor: pointer;
118
- }}
119
- #expandMenu div:hover {{
120
- background: #eee;
121
- }}
122
- #saveButton {{
123
- width: 100%;
124
- margin-top: 10px;
125
- padding: 8px;
126
- border: none;
127
- background: #4CAF50;
128
- color: white;
129
- font-weight: bold;
130
- border-radius: 6px;
131
- cursor: pointer;
132
- }}
133
- #saveButton:hover {{
134
- background: #45a049;
135
- }}
136
- </style>
137
-
138
- <div id="sidebar">
139
- <h3 style="text-align:center;">Node Details</h3>
140
- <div id="nodeInfo">
141
- <p><b>Click a node</b> to view details.</p>
142
- </div>
143
- <hr>
144
- <div id="menuBar" style="display:none; text-align:center;">
145
- <button onclick="menuAction('edit')">✏️ Edit</button>
146
- <button onclick="menuAction('delete')">🗑️ Delete</button>
147
- <button id="expandBtn" onclick="menuAction('expand')">🔽 Expand</button>
148
- </div>
149
- <div id="expandMenu"></div>
150
- <button id="saveButton" onclick="saveTree()">💾 Save Tree</button>
151
- </div>
152
-
153
- <script>
154
- var treeData = {json.dumps(tree_data)};
155
-
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){{
180
- hideExpandMenu();
181
- if(params.nodes.length > 0){{
182
- var nodeId = params.nodes[0];
183
- var node = treeData[nodeId];
184
- document.getElementById("nodeInfo").innerHTML =
185
- "<p><b>Name:</b> " + nodeId + "</p>" +
186
- "<p><b>Type:</b> " + node.type + "</p>" +
187
- "<p><b>Value:</b> " + node.value + "</p>" +
188
- "<p><b>Children:</b> " + (node.children.join(", ") || "None") + "</p>";
189
- document.getElementById("menuBar").style.display = "block";
190
- document.getElementById("menuBar").setAttribute("data-node", nodeId);
191
- }}
192
- }});
193
-
194
- // Menu actions
195
- function menuAction(action){{
196
- var nodeId = document.getElementById("menuBar").getAttribute("data-node");
197
- if(action === 'expand') showExpandMenu(treeData[nodeId]);
198
- else if(action === 'delete') deleteNode(nodeId);
199
- else alert(action + " action on node: " + nodeId);
200
- }}
201
-
202
- // Expand menu
203
- function showExpandMenu(node){{
204
- var menu = document.getElementById("expandMenu");
205
- menu.innerHTML = "";
206
- if(node.children.length === 0){{
207
- menu.innerHTML = "<div><i>No children</i></div>";
208
- }} else {{
209
- node.children.forEach(c => {{
210
- var item = document.createElement("div");
211
- item.textContent = c;
212
- if(treeData[c] && treeData[c].highlight){{
213
- item.style.color = "red";
214
- item.style.fontWeight = "bold";
215
- }}
216
- item.onclick = function(){{ alert("Selected child: " + c); hideExpandMenu(); }};
217
- menu.appendChild(item);
218
- }});
219
- }}
220
- var expandBtn = document.getElementById("expandBtn");
221
- var rect = expandBtn.getBoundingClientRect();
222
- menu.style.left = rect.left + "px";
223
- menu.style.top = (rect.bottom + window.scrollY) + "px";
224
- menu.style.display = "block";
225
- }}
226
-
227
- function hideExpandMenu(){{ document.getElementById("expandMenu").style.display = "none"; }}
228
- window.addEventListener('click', function(e){{
229
- var menu = document.getElementById("expandMenu");
230
- if(!menu.contains(e.target) && e.target.id !== 'expandBtn') hideExpandMenu();
231
- }});
232
-
233
- // Delete node
234
- function deleteNode(nodeId){{
235
- if(confirm("Delete node '" + nodeId + "'?")){{
236
- for(let key in treeData){{
237
- let idx = treeData[key].children.indexOf(nodeId);
238
- if(idx !== -1) treeData[key].children.splice(idx, 1);
239
- }}
240
- delete treeData[nodeId];
241
- network.body.data.nodes.remove({{id: nodeId}});
242
- document.getElementById("nodeInfo").innerHTML = "<p><b>Click a node</b> to view details.</p>";
243
- document.getElementById("menuBar").style.display = "none";
244
- hideExpandMenu();
245
- updateRedness();
246
- }}
247
- }}
248
-
249
- // Save tree
250
- function saveTree(){{
251
- const jsonData = JSON.stringify(treeData, null, 2);
252
- const blob = new Blob([jsonData], {{ type: "application/json" }});
253
- const url = URL.createObjectURL(blob);
254
- const a = document.createElement("a");
255
- a.href = url;
256
- a.download = "tree_data.json";
257
- document.body.appendChild(a);
258
- a.click();
259
- document.body.removeChild(a);
260
- URL.revokeObjectURL(url);
261
- }}
262
-
263
- // Initial red calculation
264
- updateRedness();
265
- </script>
266
- """
267
-
268
- with open("tree.html", "w") as f:
269
- f.write(html.replace("</body>", extra_js + "</body>"))
270
-
271
- print("✅ Open tree.html in your browser")
272
-