WIP annotations

This commit is contained in:
Ruben van de Ven 2022-06-01 16:08:49 +02:00
parent 9c54b2f8d7
commit 232903c0ff
4 changed files with 178 additions and 80 deletions

View file

@ -12,6 +12,9 @@ import svgwrite
import tempfile import tempfile
import io import io
import logging import logging
from anytree import NodeMixin, RenderTree
from anytree.exporter import JsonExporter
from anytree.importer import JsonImporter, DictImporter
logger = logging.getLogger('svganim.strokes') logger = logging.getLogger('svganim.strokes')
@ -693,3 +696,31 @@ def strokes2D(strokes):
d += f"{rel_stroke[0]},{rel_stroke[1]} " d += f"{rel_stroke[0]},{rel_stroke[1]} "
last_stroke = stroke last_stroke = stroke
return d return d
class Tag(NodeMixin):
def __init__(self, id, name = None, description = "", color = "black", parent=None, children=None):
self.id = id
self.name = self.id if name is None else name
self.color = color
self.description = description
self.parent = parent
if children:
self.children = children
class TagTree(NodeMixin):
def __init__(self, parent=None, children=None):
self.parent = parent
if children:
self.children = children
my0 = Tag('root')
my1 = Tag('my1', 1, 0, parent=my0)
my2 = Tag('my2', 0, 2, parent=my0)
print(RenderTree(my0))
tree = JsonExporter(indent=2).export(my0)
print(tree)
print(RenderTree(JsonImporter(DictImporter(Tag)).import_(tree)))
with open('www/tags.json', 'r') as fp:
print(RenderTree(JsonImporter(DictImporter(Tag)).read(fp)))

View file

@ -1,81 +1,116 @@
{ {
"human-machine": { "id": "root",
"fullname": "Human/machine Entanglements (Appearance/disappearance)", "children": [
{
"id": "human-machine",
"name": "Human/machine Entanglements (Appearance/disappearance)",
"color": "orange", "color": "orange",
"sub": { "children": [
"vision": { {
"fullname": "Vision", "id": "vision",
"name": "Vision",
"color": "orange" "color": "orange"
}, },
"sound": {}, {
"behaviour": {}, "id": "sound"
"other-senses": {
"fullname": "Other senses"
}
}
}, },
"tensions": { {
"fullname": "Tensions, contestations & problems", "id": "behaviour"
"description" : "Which problems are identified?, when do they become problems?", },
{
"id": "other-senses",
"name": "Other senses"
}
]
},
{
"id": "tensions",
"name": "Tensions, contestations & problems",
"description": "Which problems are identified?, when do they become problems?",
"color": "gray" "color": "gray"
}, },
"security": { {
"id": "security",
"color": "blue", "color": "blue",
"fullname": "Security & types of data", "name": "Security & types of data",
"sub": { "children": [
"definitions": { {
"id": "definitions",
"description": "e.g. domain knowledge" "description": "e.g. domain knowledge"
}, },
"input": { {
"id": "input",
"description": "e.g. fake data" "description": "e.g. fake data"
} }
} ]
}, },
"actants":{ {
"fullname": "Actants in relation", "id": "actants",
"name": "Actants in relation",
"color": "pink", "color": "pink",
"sub":{ "children": [
"algorithm": {}, {
"technologies": {}, "id": "algorithm"
"frt": {},
"cameras": {
"fullname": "CCTV & camera's"
}, },
"entities":{ {
"fullname": "Entities: people, institutions etc." "id": "technologies"
}, },
"positioning":{ {
"fullname": "Positioning", "id": "frt"
},
{
"id": "cameras",
"name": "CCTV & camera's"
},
{
"id": "entities",
"name": "Entities: people, institutions etc."
},
{
"id": "positioning",
"name": "Positioning",
"description": "the positioning of a field/person/oneself in relation to others" "description": "the positioning of a field/person/oneself in relation to others"
}, },
"inside-outside":{}, {
"public-private":{} "id": "inside-outside"
}
}, },
"consequences":{ {
"id": "public-private"
}
]
},
{
"id": "consequences",
"color": "green", "color": "green",
"sub":{ "children": [
"effects":{}, {
"future-imaginaries":{}, "id": "effects"
"speculations": { },
{
"id": "future-imaginaries"
},
{
"id": "speculations",
"description": "what is & what will/can be done." "description": "what is & what will/can be done."
}, },
"innovations": {} {
"id": "innovations"
} }
]
}, },
{
"hesitation":{ "id": "hesitation",
"fullname": "Hesitations & corrections", "name": "Hesitations & corrections",
"color": "yellow" "color": "yellow"
}, },
{
"skip":{ "id": "skip",
"color": "black" "color": "black"
}, },
{
"todo":{ "id": "todo",
"fullname": "to do / interesting", "name": "to do / interesting",
"color": "red" "color": "red"
} }
]
} }

33
poetry.lock generated
View file

@ -1,3 +1,18 @@
[[package]]
name = "anytree"
version = "2.8.0"
description = "Powerful and Lightweight Python Tree Data Structure.."
category = "main"
optional = false
python-versions = "*"
[package.dependencies]
six = ">=1.9.0"
[package.extras]
dev = ["check-manifest"]
test = ["coverage"]
[[package]] [[package]]
name = "coloredlogs" name = "coloredlogs"
version = "15.0.1" version = "15.0.1"
@ -39,6 +54,14 @@ category = "dev"
optional = false optional = false
python-versions = "*" python-versions = "*"
[[package]]
name = "six"
version = "1.16.0"
description = "Python 2 and 3 compatibility utilities"
category = "main"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
[[package]] [[package]]
name = "svgwrite" name = "svgwrite"
version = "1.4.2" version = "1.4.2"
@ -58,9 +81,13 @@ python-versions = ">= 3.5"
[metadata] [metadata]
lock-version = "1.1" lock-version = "1.1"
python-versions = "^3.9" python-versions = "^3.9"
content-hash = "b989d535550aaf74b32cd9d2ff48ab7ed8d7d3fd5f0386bc2d6385d65adbf438" content-hash = "1ad87cd5b37157a20ee2ec8f23d84b0275ca9f3aa3218c98eb18859d43aa5080"
[metadata.files] [metadata.files]
anytree = [
{file = "anytree-2.8.0-py2.py3-none-any.whl", hash = "sha256:14c55ac77492b11532395049a03b773d14c7e30b22aa012e337b1e983de31521"},
{file = "anytree-2.8.0.tar.gz", hash = "sha256:3f0f93f355a91bc3e6245319bf4c1d50e3416cc7a35cc1133c1ff38306bbccab"},
]
coloredlogs = [ coloredlogs = [
{file = "coloredlogs-15.0.1-py2.py3-none-any.whl", hash = "sha256:612ee75c546f53e92e70049c9dbfcc18c935a2b9a53b66085ce9ef6a6e5c0934"}, {file = "coloredlogs-15.0.1-py2.py3-none-any.whl", hash = "sha256:612ee75c546f53e92e70049c9dbfcc18c935a2b9a53b66085ce9ef6a6e5c0934"},
{file = "coloredlogs-15.0.1.tar.gz", hash = "sha256:7c991aa71a4577af2f82600d8f8f3a89f936baeaf9b50a9c197da014e5bf16b0"}, {file = "coloredlogs-15.0.1.tar.gz", hash = "sha256:7c991aa71a4577af2f82600d8f8f3a89f936baeaf9b50a9c197da014e5bf16b0"},
@ -77,6 +104,10 @@ pyreadline3 = [
{file = "pyreadline3-3.4.1-py3-none-any.whl", hash = "sha256:b0efb6516fd4fb07b45949053826a62fa4cb353db5be2bbb4a7aa1fdd1e345fb"}, {file = "pyreadline3-3.4.1-py3-none-any.whl", hash = "sha256:b0efb6516fd4fb07b45949053826a62fa4cb353db5be2bbb4a7aa1fdd1e345fb"},
{file = "pyreadline3-3.4.1.tar.gz", hash = "sha256:6f3d1f7b8a31ba32b73917cefc1f28cc660562f39aea8646d30bd6eff21f7bae"}, {file = "pyreadline3-3.4.1.tar.gz", hash = "sha256:6f3d1f7b8a31ba32b73917cefc1f28cc660562f39aea8646d30bd6eff21f7bae"},
] ]
six = [
{file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"},
{file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"},
]
svgwrite = [ svgwrite = [
{file = "svgwrite-1.4.2-py3-none-any.whl", hash = "sha256:ca63d76396d1f6f099a2b2d8cf1419e1c1de8deece9a2b7f4da0632067d71d43"}, {file = "svgwrite-1.4.2-py3-none-any.whl", hash = "sha256:ca63d76396d1f6f099a2b2d8cf1419e1c1de8deece9a2b7f4da0632067d71d43"},
{file = "svgwrite-1.4.2.zip", hash = "sha256:d304a929f197d31647c287c10eee0f64378058e1c83a9df83433a5980864e59f"}, {file = "svgwrite-1.4.2.zip", hash = "sha256:d304a929f197d31647c287c10eee0f64378058e1c83a9df83433a5980864e59f"},

View file

@ -10,6 +10,7 @@ tornado = "^6.1"
coloredlogs = "^15.0.1" coloredlogs = "^15.0.1"
pydub = "^0.25.1" pydub = "^0.25.1"
svgwrite = "^1.4.1" svgwrite = "^1.4.1"
anytree = "^2.8.0"
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]