anxwritter 1.0.0__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.
- anxwritter/__init__.py +93 -0
- anxwritter/_i2_interop.py +102 -0
- anxwritter/builder.py +2573 -0
- anxwritter/chart.py +1810 -0
- anxwritter/cli.py +357 -0
- anxwritter/colors.py +118 -0
- anxwritter/entities.py +318 -0
- anxwritter/enums.py +212 -0
- anxwritter/errors.py +91 -0
- anxwritter/models.py +731 -0
- anxwritter/resolved.py +135 -0
- anxwritter/semantic.py +216 -0
- anxwritter/timezones.json +124 -0
- anxwritter/timing.py +53 -0
- anxwritter/transforms.py +447 -0
- anxwritter/utils.py +125 -0
- anxwritter/validation.py +1248 -0
- anxwritter-1.0.0.dist-info/METADATA +163 -0
- anxwritter-1.0.0.dist-info/RECORD +23 -0
- anxwritter-1.0.0.dist-info/WHEEL +4 -0
- anxwritter-1.0.0.dist-info/entry_points.txt +2 -0
- anxwritter-1.0.0.dist-info/licenses/LICENSE +21 -0
- anxwritter-1.0.0.dist-info/licenses/NOTICE.md +37 -0
anxwritter/__init__.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"""
|
|
2
|
+
anxwritter — Convert typed Python objects to i2 Analyst's Notebook Exchange (.anx) files.
|
|
3
|
+
|
|
4
|
+
Quick start
|
|
5
|
+
-----------
|
|
6
|
+
::
|
|
7
|
+
|
|
8
|
+
from anxwritter import ANXChart
|
|
9
|
+
|
|
10
|
+
chart = ANXChart()
|
|
11
|
+
|
|
12
|
+
chart.add_icon(id='Alice', type='Person', color='Blue',
|
|
13
|
+
attributes={'phone': '555-0001'})
|
|
14
|
+
chart.add_icon(id='Bob', type='Person')
|
|
15
|
+
|
|
16
|
+
chart.add_link(from_id='Alice', to_id='Bob', type='Call',
|
|
17
|
+
arrow='->', date='2024-01-15',
|
|
18
|
+
attributes={'duration': 120})
|
|
19
|
+
|
|
20
|
+
chart.to_anx('output/my_chart') # writes output/my_chart.anx
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
from importlib.metadata import version, metadata, PackageNotFoundError
|
|
24
|
+
|
|
25
|
+
from loguru import logger
|
|
26
|
+
|
|
27
|
+
from .chart import ANXChart
|
|
28
|
+
from .errors import ANXValidationError, ErrorType
|
|
29
|
+
from .colors import NAMED_COLORS, color_to_colorref, rgb_to_colorref
|
|
30
|
+
from .enums import VALID_SHADING_COLORS, MergeBehaviour, DotStyle, Enlargement, AttributeType, Multiplicity, ThemeWiring, ArrowStyle, Representation, LegendItemType, Color
|
|
31
|
+
from .entities import Icon, Box, Circle, ThemeLine, EventFrame, TextBlock, Label
|
|
32
|
+
from .models import (
|
|
33
|
+
Card, Link, AttributeClass, Strength, LegendItem, EntityType, LinkType,
|
|
34
|
+
Palette, PaletteAttributeEntry, DateTimeFormat,
|
|
35
|
+
SemanticEntity, SemanticLink, SemanticProperty,
|
|
36
|
+
Font, Frame, Show, TimeZone, CustomProperty,
|
|
37
|
+
GradeCollection, StrengthCollection,
|
|
38
|
+
Settings, ChartCfg, ViewCfg, GridCfg, WiringCfg, LinksCfg, TimeCfg,
|
|
39
|
+
SummaryCfg, LegendCfg, ExtraCfg, GeoMapCfg,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
try:
|
|
43
|
+
__version__ = version("anxwritter")
|
|
44
|
+
_meta = metadata("anxwritter")
|
|
45
|
+
__repo_url__ = ""
|
|
46
|
+
for val in _meta.get_all("Project-URL") or []:
|
|
47
|
+
label, url = val.split(", ", 1)
|
|
48
|
+
if label == "Repository":
|
|
49
|
+
__repo_url__ = url
|
|
50
|
+
break
|
|
51
|
+
except PackageNotFoundError:
|
|
52
|
+
__version__ = "0.0.0"
|
|
53
|
+
__repo_url__ = ""
|
|
54
|
+
|
|
55
|
+
logger.disable("anxwritter")
|
|
56
|
+
|
|
57
|
+
__all__ = [
|
|
58
|
+
# Version
|
|
59
|
+
'__version__',
|
|
60
|
+
# Main class
|
|
61
|
+
'ANXChart',
|
|
62
|
+
'ANXValidationError',
|
|
63
|
+
'ErrorType',
|
|
64
|
+
# Entity classes
|
|
65
|
+
'Icon', 'Box', 'Circle', 'ThemeLine', 'EventFrame', 'TextBlock', 'Label',
|
|
66
|
+
# Chart item classes
|
|
67
|
+
'Card', 'Link', 'AttributeClass', 'Strength', 'LegendItem',
|
|
68
|
+
'GradeCollection', 'StrengthCollection',
|
|
69
|
+
'EntityType', 'LinkType',
|
|
70
|
+
'Palette', 'PaletteAttributeEntry',
|
|
71
|
+
'DateTimeFormat',
|
|
72
|
+
'SemanticEntity', 'SemanticLink', 'SemanticProperty',
|
|
73
|
+
# Settings dataclasses
|
|
74
|
+
'Font', 'Frame', 'Show', 'TimeZone', 'CustomProperty', 'Settings',
|
|
75
|
+
'ChartCfg', 'ViewCfg', 'GridCfg', 'WiringCfg', 'LinksCfg', 'TimeCfg',
|
|
76
|
+
'SummaryCfg', 'LegendCfg', 'ExtraCfg', 'GeoMapCfg',
|
|
77
|
+
# Enums
|
|
78
|
+
'MergeBehaviour',
|
|
79
|
+
'DotStyle',
|
|
80
|
+
'Enlargement',
|
|
81
|
+
'AttributeType',
|
|
82
|
+
'Multiplicity',
|
|
83
|
+
'ThemeWiring',
|
|
84
|
+
'ArrowStyle',
|
|
85
|
+
'Representation',
|
|
86
|
+
'LegendItemType',
|
|
87
|
+
'Color',
|
|
88
|
+
# Color helpers
|
|
89
|
+
'VALID_SHADING_COLORS',
|
|
90
|
+
'NAMED_COLORS',
|
|
91
|
+
'color_to_colorref',
|
|
92
|
+
'rgb_to_colorref',
|
|
93
|
+
]
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"""
|
|
2
|
+
_i2_interop.py — Minimum interoperability constants for the ANX format.
|
|
3
|
+
|
|
4
|
+
This module contains the only i2-derived identifiers this library ships:
|
|
5
|
+
|
|
6
|
+
* Six abstract-root GUIDs required by ANB's ``lcx:LibraryCatalogue`` schema.
|
|
7
|
+
Every semantic type chain must terminate at one of these roots; they are
|
|
8
|
+
structural anchors, not content.
|
|
9
|
+
|
|
10
|
+
* Three geo-map property GUIDs required by ANB's Esri Maps subsystem to
|
|
11
|
+
recognise Latitude/Longitude attributes for geographic rendering.
|
|
12
|
+
|
|
13
|
+
These nine identifiers are the absolute minimum needed to write a structurally
|
|
14
|
+
valid ANX file with semantic types. This library intentionally ships nothing
|
|
15
|
+
else from i2's type system — no standard-library types (Person, Vehicle,
|
|
16
|
+
Phone Call…), no icon catalog, no palette definitions. All of that content
|
|
17
|
+
belongs to the user's licensed ANB installation and must be supplied by the
|
|
18
|
+
user via config files or ``.ant``/``.anx`` reference files.
|
|
19
|
+
|
|
20
|
+
This design is intentional: it leaves organisations free to define their own
|
|
21
|
+
default semantic types, palettes, icon mappings, link types, and attribute
|
|
22
|
+
classes — either independently of i2's standard library or layered on top of
|
|
23
|
+
it using types extracted from their own ANB installation.
|
|
24
|
+
|
|
25
|
+
These nine identifiers are functional tokens (format anchors), not creative
|
|
26
|
+
works, reproduced under the interoperability doctrine
|
|
27
|
+
(EU Directive 2009/24/EC Art. 6).
|
|
28
|
+
"""
|
|
29
|
+
from __future__ import annotations
|
|
30
|
+
|
|
31
|
+
from typing import Dict, Set
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
# ── Group 1: abstract root GUIDs ─────────────────────────────────────────────
|
|
35
|
+
|
|
36
|
+
#: i2 abstract root for every entity type. Parent of any user-defined
|
|
37
|
+
#: ``kind_of: Entity`` chain. Required by ANB schema.
|
|
38
|
+
ROOT_ENTITY = 'guid3669EC21-8E41-438A-AA1A-26B477C15BE0'
|
|
39
|
+
|
|
40
|
+
#: i2 abstract root for every link type. Parent of any user-defined
|
|
41
|
+
#: ``kind_of: Link`` chain. Required by ANB schema.
|
|
42
|
+
ROOT_LINK = 'guidC9E54967-BBBF-494B-8348-B9D524F500FD'
|
|
43
|
+
|
|
44
|
+
#: i2 abstract root for text-typed semantic properties.
|
|
45
|
+
ROOT_ABSTRACT_TEXT = 'guid9A224CCF-28F7-4c55-9F14-9E820A0B1631'
|
|
46
|
+
|
|
47
|
+
#: i2 abstract root for numeric-typed semantic properties. Also the indirect
|
|
48
|
+
#: ancestor of the geo-map ``Grid Reference`` / ``Latitude`` / ``Longitude``
|
|
49
|
+
#: property tree.
|
|
50
|
+
ROOT_ABSTRACT_NUM = 'guid6D676796-915D-487f-B384-73503C988ABE'
|
|
51
|
+
|
|
52
|
+
#: i2 abstract root for datetime-typed semantic properties.
|
|
53
|
+
ROOT_ABSTRACT_DT = 'guid6684F871-B607-4ffb-80E8-480535CB44FC'
|
|
54
|
+
|
|
55
|
+
#: i2 abstract root for flag/boolean semantic properties.
|
|
56
|
+
ROOT_ABSTRACT_FLAG = 'guid74F2A516-2F49-4282-989F-F4A468656FF0'
|
|
57
|
+
|
|
58
|
+
#: All six abstract roots.
|
|
59
|
+
ROOTS: Set[str] = {
|
|
60
|
+
ROOT_ENTITY, ROOT_LINK,
|
|
61
|
+
ROOT_ABSTRACT_TEXT, ROOT_ABSTRACT_NUM,
|
|
62
|
+
ROOT_ABSTRACT_DT, ROOT_ABSTRACT_FLAG,
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
#: Type-tree roots (entity + link). Used to distinguish from property roots
|
|
66
|
+
#: when populating the catalogue's type vs. property lookups.
|
|
67
|
+
TYPE_ROOTS: Set[str] = {ROOT_ENTITY, ROOT_LINK}
|
|
68
|
+
|
|
69
|
+
#: Property-tree roots (text/number/datetime/flag).
|
|
70
|
+
PROPERTY_ROOTS: Set[str] = {
|
|
71
|
+
ROOT_ABSTRACT_TEXT, ROOT_ABSTRACT_NUM,
|
|
72
|
+
ROOT_ABSTRACT_DT, ROOT_ABSTRACT_FLAG,
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
#: Display name for each root, emitted as the ``<TypeName>`` /
|
|
76
|
+
#: ``<PropertyName>`` of root catalogue entries.
|
|
77
|
+
ROOT_NAMES: Dict[str, str] = {
|
|
78
|
+
ROOT_ENTITY: 'Entity',
|
|
79
|
+
ROOT_LINK: 'Link',
|
|
80
|
+
ROOT_ABSTRACT_TEXT: 'Abstract Text',
|
|
81
|
+
ROOT_ABSTRACT_NUM: 'Abstract Number',
|
|
82
|
+
ROOT_ABSTRACT_DT: 'Abstract Date & Time',
|
|
83
|
+
ROOT_ABSTRACT_FLAG: 'Abstract Flag',
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
# ── Group 2: geo-map property GUIDs ──────────────────────────────────────────
|
|
88
|
+
|
|
89
|
+
#: i2 standard "Latitude" semantic property GUID. Required for ANB's Esri
|
|
90
|
+
#: Maps subsystem to recognise a Latitude attribute for geographic rendering.
|
|
91
|
+
#: Used only when ``geo_map.mode`` is ``'latlon'`` or ``'both'``.
|
|
92
|
+
LATITUDE_GUID = 'guid5304A03B-FE47-4406-91E7-0D49EC8409A6'
|
|
93
|
+
|
|
94
|
+
#: i2 standard "Longitude" semantic property GUID. Paired with
|
|
95
|
+
#: :data:`LATITUDE_GUID`.
|
|
96
|
+
LONGITUDE_GUID = 'guid14BCA0EC-D67A-4A67-BC36-CFF650FD77A9'
|
|
97
|
+
|
|
98
|
+
#: i2 standard "Grid Reference" semantic property GUID. Parent of Latitude
|
|
99
|
+
#: and Longitude in the property tree (chains up to ``Abstract Number``).
|
|
100
|
+
#: Required because Latitude/Longitude need a non-abstract parent to be
|
|
101
|
+
#: valid in the catalogue chain.
|
|
102
|
+
GRID_REFERENCE_GUID = 'guid7E0F705E-3D39-4E6E-B6C1-5E72B8C573DA'
|