|
18 | 18 |
|
19 | 19 | """ |
20 | 20 |
|
| 21 | +import json |
21 | 22 | from datetime import datetime |
22 | | -from zoneinfo import ZoneInfo |
| 23 | +from typing import TypeVar |
23 | 24 |
|
24 | 25 | from immanuel.classes import wrap |
25 | 26 | from immanuel.classes.localize import localize as _ |
| 27 | +from immanuel.classes.serialize import ToJSON |
26 | 28 | from immanuel.const import calc, chart, names |
27 | 29 | from immanuel.reports import aspect, dignity, pattern, weighting |
28 | 30 | from immanuel.setup import settings |
|
36 | 38 | ) |
37 | 39 |
|
38 | 40 |
|
| 41 | +ChartType = TypeVar("ChartType", bound="Chart") |
| 42 | + |
| 43 | + |
39 | 44 | class Subject: |
40 | 45 | """Simple class to model a chart subject - essentially just |
41 | 46 | a time and place.""" |
@@ -71,7 +76,7 @@ class Chart: |
71 | 76 | """Base chart class. This acts as an abstract class for the actual chart |
72 | 77 | classes to inherit from.""" |
73 | 78 |
|
74 | | - def __init__(self, type: int, aspects_to: "Chart" = None) -> None: |
| 79 | + def __init__(self, type: int, aspects_to: ChartType | None = None) -> None: |
75 | 80 | self.type = _(names.CHART_TYPES[type]) |
76 | 81 | self._type = type |
77 | 82 | self._aspects_to = aspects_to |
@@ -217,6 +222,9 @@ def set_wrapped_weightings(self) -> None: |
217 | 222 | quadrants=weighting.quadrants(self._objects, self._houses), |
218 | 223 | ) |
219 | 224 |
|
| 225 | + def to_json(self, **kwargs) -> str: |
| 226 | + return json.dumps(self, cls=ToJSON, **kwargs) |
| 227 | + |
220 | 228 |
|
221 | 229 | class Natal(Chart): |
222 | 230 | """Standard natal chart generates data straight from the passed |
|
0 commit comments