home » dokk/dokk.org.git
Author zPlus <zplus@peers.community> 2022-08-28 03:49:34
Committer zPlus <zplus@peers.community> 2022-08-28 03:49:34
Commit cf0e07f (patch)
Tree d59ad55
Parent(s)

Add support for "*" edges.


commits diff: 2a9ed72..cf0e07f
1 file changed, 7 insertions, 9 deletionsdownload


Diffstat
-rwxr-xr-x mknodes.py 16

Diff options
View
Side
Whitespace
Context lines
Inter-hunk lines
+7/-9 M   mknodes.py
index 712e478..15619af
old size: 1K - new size: 1K
@@ -9,8 +9,6 @@ import json
9 9 from pathlib import Path
10 10
11 11 data = '../dokk/data'
12 - edge_properties = [ 'comics_cartoon', 'comics_author', 'ttrpg_character',
13 - 'community_project' ]
14 12
15 13 nodes = []
16 14 edges = []
@@ -18,24 +16,24 @@ edges = []
18 16 for path in Path(data).glob('**/*.json',):
19 17 with open(path, 'r') as f:
20 18 n = json.loads(f.read())
21 -
19 +
22 20 nodes.append({
23 21 'title': n['node_name'] + ('\n' + n['node_description'] if 'node_description' in n else ''),
24 22 #'color': { 'background': '', 'border': ''},
25 23 'label': n['node_name'],
26 24 'id': n['node_id']
27 25 })
28 -
29 - for p in edge_properties:
30 - if p not in n.keys():
26 +
27 + for p in n.keys():
28 + if not p.startswith('*'):
31 29 continue
32 -
30 +
33 31 if not type(n[p]) == list:
34 32 n[p] = [ n[p] ]
35 -
33 +
36 34 for target in n[p]:
37 35 edges.append({
38 - 'title': p,
36 + 'title': p[1:],
39 37 'from': n['node_id'],
40 38 #'label': p,
41 39 'to': target,