kerykeion 4.2.3__tar.gz → 4.3.0__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 kerykeion might be problematic. Click here for more details.

Files changed (29) hide show
  1. {kerykeion-4.2.3 → kerykeion-4.3.0}/PKG-INFO +2 -2
  2. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/aspects/natal_aspects.py +10 -20
  3. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/aspects/synastry_aspects.py +12 -10
  4. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/astrological_subject.py +12 -18
  5. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/charts/kerykeion_chart_svg.py +13 -19
  6. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/fetch_geonames.py +10 -22
  7. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/kr_types/__init__.py +2 -2
  8. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/kr_types/chart_types.py +19 -28
  9. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/kr_types/kr_models.py +6 -2
  10. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/kr_types/settings_models.py +0 -5
  11. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/relationship_score.py +5 -11
  12. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/report.py +3 -0
  13. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/settings/kerykeion_settings.py +5 -8
  14. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/utilities.py +15 -4
  15. {kerykeion-4.2.3 → kerykeion-4.3.0}/pyproject.toml +2 -2
  16. {kerykeion-4.2.3 → kerykeion-4.3.0}/LICENSE +0 -0
  17. {kerykeion-4.2.3 → kerykeion-4.3.0}/README.md +0 -0
  18. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/__init__.py +0 -0
  19. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/aspects/__init__.py +0 -0
  20. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/aspects/aspects_utils.py +0 -0
  21. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/charts/__init__.py +0 -0
  22. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/charts/charts_utils.py +0 -0
  23. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/charts/templates/chart.xml +0 -0
  24. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/kr_types/kerykeion_exception.py +0 -0
  25. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/kr_types/kr_literals.py +0 -0
  26. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/settings/__init__.py +0 -0
  27. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/settings/kr.config.json +0 -0
  28. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/sweph/README.md +0 -0
  29. {kerykeion-4.2.3 → kerykeion-4.3.0}/kerykeion/sweph/seas_18.se1 +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kerykeion
3
- Version: 4.2.3
3
+ Version: 4.3.0
4
4
  Summary: A python library for astrology.
5
5
  Home-page: https://github.com/g-battaglia/kerykeion
6
6
  License: AGPL-3.0
@@ -24,7 +24,7 @@ Classifier: Topic :: Software Development
24
24
  Classifier: Topic :: Software Development :: Libraries
25
25
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
26
  Classifier: Typing :: Typed
27
- Requires-Dist: pydantic (>=1.10.4,<2.0.0)
27
+ Requires-Dist: pydantic (>=2.5,<3.0)
28
28
  Requires-Dist: pyswisseph (>=2.10.3.1,<3.0.0.0)
29
29
  Requires-Dist: pytz (>=2022.7,<2023.0)
30
30
  Requires-Dist: requests (>=2.28.1,<3.0.0)
@@ -5,14 +5,13 @@
5
5
 
6
6
  from pathlib import Path
7
7
  from kerykeion import AstrologicalSubject
8
- from logging import getLogger, basicConfig
8
+ import logging
9
9
  from typing import Union
10
10
  from kerykeion.settings.kerykeion_settings import get_settings
11
11
  from dataclasses import dataclass
12
+ from functools import cached_property
12
13
  from kerykeion.aspects.aspects_utils import planet_id_decoder, get_aspect_from_two_points, get_active_points_list
13
14
 
14
- logger = getLogger(__name__)
15
- basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level="INFO")
16
15
 
17
16
  AXES_LIST = [
18
17
  "First_House",
@@ -21,6 +20,7 @@ AXES_LIST = [
21
20
  "Fourth_House",
22
21
  ]
23
22
 
23
+
24
24
  @dataclass
25
25
  class NatalAspects:
26
26
  """
@@ -29,8 +29,6 @@ class NatalAspects:
29
29
 
30
30
  user: AstrologicalSubject
31
31
  new_settings_file: Union[Path, None] = None
32
- _all_aspects: Union[list, None] = None
33
- _relevant_aspects: Union[list, None] = None
34
32
 
35
33
  def __post_init__(self):
36
34
  self.settings = get_settings(self.new_settings_file)
@@ -39,7 +37,7 @@ class NatalAspects:
39
37
  self.aspects_settings = self.settings["aspects"]
40
38
  self.axes_orbit_settings = self.settings["general_settings"]["axes_orbit"]
41
39
 
42
- @property
40
+ @cached_property
43
41
  def all_aspects(self):
44
42
  """
45
43
  Return all the aspects of the points in the natal chart in a dictionary,
@@ -47,9 +45,6 @@ class NatalAspects:
47
45
  without repetitions.
48
46
  """
49
47
 
50
- if self._all_aspects is not None:
51
- return self._all_aspects
52
-
53
48
  active_points_list = get_active_points_list(self.user, self.settings)
54
49
 
55
50
  self.all_aspects_list = []
@@ -73,10 +68,7 @@ class NatalAspects:
73
68
  "color": color,
74
69
  "aid": aid,
75
70
  "diff": diff,
76
- "p1": planet_id_decoder(
77
- self.celestial_points,
78
- active_points_list[first]["name"]
79
- ),
71
+ "p1": planet_id_decoder(self.celestial_points, active_points_list[first]["name"]),
80
72
  "p2": planet_id_decoder(
81
73
  self.celestial_points,
82
74
  active_points_list[second]["name"],
@@ -87,7 +79,7 @@ class NatalAspects:
87
79
 
88
80
  return self.all_aspects_list
89
81
 
90
- @property
82
+ @cached_property
91
83
  def relevant_aspects(self):
92
84
  """
93
85
  Filters the aspects list with the desired points, in this case
@@ -96,11 +88,7 @@ class NatalAspects:
96
88
  or the numbers of the houses.
97
89
  """
98
90
 
99
- if self._relevant_aspects is not None:
100
- logger.debug("Relevant aspects already calculated, returning cached value")
101
- return self._relevant_aspects
102
-
103
- logger.debug("Relevant aspects not already calculated, calculating now...")
91
+ logging.debug("Relevant aspects not already calculated, calculating now...")
104
92
  self.all_aspects
105
93
 
106
94
  aspects_filtered = []
@@ -131,7 +119,9 @@ class NatalAspects:
131
119
 
132
120
 
133
121
  if __name__ == "__main__":
134
- basicConfig(level="DEBUG", force=True)
122
+ from kerykeion.utilities import setup_logging
123
+ setup_logging(level="debug")
124
+
135
125
  johnny = AstrologicalSubject("Johnny Depp", 1963, 6, 9, 0, 0, "Owensboro", "US")
136
126
 
137
127
  # All aspects
@@ -6,6 +6,7 @@
6
6
  from kerykeion import AstrologicalSubject
7
7
  from pathlib import Path
8
8
  from typing import Union
9
+ from functools import cached_property
9
10
 
10
11
  from kerykeion.aspects.natal_aspects import NatalAspects
11
12
  from kerykeion.settings.kerykeion_settings import get_settings
@@ -26,11 +27,11 @@ class SynastryAspects(NatalAspects):
26
27
  # Subjects
27
28
  self.first_user = kr_object_one
28
29
  self.second_user = kr_object_two
29
-
30
+
30
31
  # Settings
31
32
  self.new_settings_file = new_settings_file
32
33
  self.settings = get_settings(self.new_settings_file)
33
-
34
+
34
35
  self.celestial_points = self.settings["celestial_points"]
35
36
  self.aspects_settings = self.settings["aspects"]
36
37
  self.axes_orbit_settings = self.settings["general_settings"]["axes_orbit"]
@@ -39,10 +40,7 @@ class SynastryAspects(NatalAspects):
39
40
  self._all_aspects: Union[list, None] = None
40
41
  self._relevant_aspects: Union[list, None] = None
41
42
 
42
-
43
-
44
-
45
- @property
43
+ @cached_property
46
44
  def all_aspects(self):
47
45
  """
48
46
  Return all the aspects of the points in the natal chart in a dictionary,
@@ -52,7 +50,7 @@ class SynastryAspects(NatalAspects):
52
50
 
53
51
  if self._all_aspects is not None:
54
52
  return self._all_aspects
55
-
53
+
56
54
  # Celestial Points Lists
57
55
  first_active_points_list = get_active_points_list(self.first_user, self.settings)
58
56
  second_active_points_list = get_active_points_list(self.second_user, self.settings)
@@ -63,7 +61,9 @@ class SynastryAspects(NatalAspects):
63
61
  # Generates the aspects list whitout repetitions
64
62
  for second in range(len(second_active_points_list)):
65
63
  verdict, name, orbit, aspect_degrees, color, aid, diff = get_aspect_from_two_points(
66
- self.aspects_settings, first_active_points_list[first]["abs_pos"], second_active_points_list[second]["abs_pos"]
64
+ self.aspects_settings,
65
+ first_active_points_list[first]["abs_pos"],
66
+ second_active_points_list[second]["abs_pos"],
67
67
  )
68
68
 
69
69
  if verdict == True:
@@ -79,8 +79,7 @@ class SynastryAspects(NatalAspects):
79
79
  "aid": aid,
80
80
  "diff": diff,
81
81
  "p1": planet_id_decoder(
82
- self.settings.celestial_points,
83
- first_active_points_list[first]["name"]
82
+ self.settings.celestial_points, first_active_points_list[first]["name"]
84
83
  ),
85
84
  "p2": planet_id_decoder(
86
85
  self.settings.celestial_points,
@@ -94,6 +93,9 @@ class SynastryAspects(NatalAspects):
94
93
 
95
94
 
96
95
  if __name__ == "__main__":
96
+ from kerykeion.utilities import setup_logging
97
+ setup_logging(level="debug")
98
+
97
99
  john = AstrologicalSubject("John", 1940, 10, 9, 10, 30, "Liverpool")
98
100
  yoko = AstrologicalSubject("Yoko", 1933, 2, 18, 10, 30, "Tokyo")
99
101
 
@@ -6,9 +6,9 @@
6
6
  import math
7
7
  import pytz
8
8
  import swisseph as swe
9
+ import logging
9
10
 
10
11
  from datetime import datetime
11
- from logging import getLogger, basicConfig
12
12
  from kerykeion.fetch_geonames import FetchGeonames
13
13
  from kerykeion.kr_types import (
14
14
  KerykeionException,
@@ -23,12 +23,6 @@ from typing import Union, Literal
23
23
 
24
24
  DEFAULT_GEONAMES_USERNAME = "century.boy"
25
25
 
26
- logger = getLogger(__name__)
27
- basicConfig(
28
- format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
29
- level="INFO"
30
- )
31
-
32
26
 
33
27
  class AstrologicalSubject:
34
28
  """
@@ -51,7 +45,6 @@ class AstrologicalSubject:
51
45
  - lng (Union[int, float], optional): _ Defaults to False.
52
46
  - lat (Union[int, float], optional): _ Defaults to False.
53
47
  - tz_str (Union[str, bool], optional): _ Defaults to False.
54
- - logger (Union[Logger, None], optional): _ Defaults to None.
55
48
  - geonames_username (str, optional): _ Defaults to 'century.boy'.
56
49
  - online (bool, optional): Sets if you want to use the online mode (using
57
50
  geonames) or not. Defaults to True.
@@ -136,7 +129,7 @@ class AstrologicalSubject:
136
129
  zodiac_type: ZodiacType = "Tropic",
137
130
  online: bool = True,
138
131
  ) -> None:
139
- logger.debug("Starting Kerykeion")
132
+ logging.debug("Starting Kerykeion")
140
133
 
141
134
  # We set the swisseph path to the current directory
142
135
  swe.set_ephe_path(
@@ -163,7 +156,7 @@ class AstrologicalSubject:
163
156
 
164
157
  # This message is set to encourage the user to set a custom geonames username
165
158
  if geonames_username is None and online:
166
- logger.info(
159
+ logging.info(
167
160
  "\n"
168
161
  "********" + \
169
162
  "\n" + \
@@ -184,11 +177,11 @@ class AstrologicalSubject:
184
177
 
185
178
  if not self.city:
186
179
  self.city = "London"
187
- logger.warning("No city specified, using London as default")
180
+ logging.warning("No city specified, using London as default")
188
181
 
189
182
  if not self.nation:
190
183
  self.nation = "GB"
191
- logger.warning("No nation specified, using GB as default")
184
+ logging.warning("No nation specified, using GB as default")
192
185
 
193
186
  if (not self.online) and (not lng or not lat or not tz_str):
194
187
  raise KerykeionException(
@@ -219,7 +212,7 @@ class AstrologicalSubject:
219
212
 
220
213
  def _fetch_tz_from_geonames(self) -> None:
221
214
  """Gets the nearest time zone for the calculation"""
222
- logger.debug("Conneting to Geonames...")
215
+ logging.debug("Conneting to Geonames...")
223
216
 
224
217
  geonames = FetchGeonames(
225
218
  self.city,
@@ -243,11 +236,11 @@ class AstrologicalSubject:
243
236
 
244
237
  if self.lat > 66.0:
245
238
  self.lat = 66.0
246
- logger.info("Polar circle override for houses, using 66 degrees")
239
+ logging.info("Polar circle override for houses, using 66 degrees")
247
240
 
248
241
  elif self.lat < -66.0:
249
242
  self.lat = -66.0
250
- logger.info("Polar circle override for houses, using -66 degrees")
243
+ logging.info("Polar circle override for houses, using -66 degrees")
251
244
 
252
245
  def _get_utc(self) -> None:
253
246
  """Converts local time to utc time."""
@@ -595,7 +588,7 @@ class AstrologicalSubject:
595
588
  """
596
589
 
597
590
  KrData = AstrologicalSubjectModel(**self.__dict__)
598
- json_string = KrData.json(exclude_none=True)
591
+ json_string = KrData.model_dump_json(exclude_none=True)
599
592
  print(json_string)
600
593
 
601
594
  if dump:
@@ -608,7 +601,7 @@ class AstrologicalSubject:
608
601
 
609
602
  with open(json_path, "w", encoding="utf-8") as file:
610
603
  file.write(json_string)
611
- logger.info(f"JSON file dumped in {json_path}.")
604
+ logging.info(f"JSON file dumped in {json_path}.")
612
605
 
613
606
  return json_string
614
607
 
@@ -622,7 +615,8 @@ class AstrologicalSubject:
622
615
 
623
616
  if __name__ == "__main__":
624
617
  import json
625
- basicConfig(level="DEBUG", force=True)
618
+ from kerykeion.utilities import setup_logging
619
+ setup_logging(level="debug")
626
620
 
627
621
  johnny = AstrologicalSubject("Johnny Depp", 1963, 6, 9, 0, 0, "Owensboro", "US")
628
622
  print(json.loads(johnny.json(dump=True)))
@@ -5,6 +5,7 @@
5
5
 
6
6
 
7
7
  import pytz
8
+ import logging
8
9
 
9
10
  from datetime import datetime
10
11
  from kerykeion.settings.kerykeion_settings import get_settings
@@ -12,21 +13,13 @@ from kerykeion.aspects.synastry_aspects import SynastryAspects
12
13
  from kerykeion.aspects.natal_aspects import NatalAspects
13
14
  from kerykeion.astrological_subject import AstrologicalSubject
14
15
  from kerykeion.kr_types import KerykeionException, ChartType
15
- from kerykeion.kr_types import ChartTemplateModel
16
+ from kerykeion.kr_types import ChartTemplateDictionary
16
17
  from kerykeion.charts.charts_utils import decHourJoin, degreeDiff, offsetToTz, sliceToX, sliceToY
17
- from logging import getLogger, basicConfig
18
18
  from pathlib import Path
19
19
  from string import Template
20
20
  from typing import Union
21
21
 
22
22
 
23
- logger = getLogger(__name__)
24
- basicConfig(
25
- format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
26
- level="INFO"
27
- )
28
-
29
-
30
23
  class KerykeionChartSVG:
31
24
  """
32
25
  Creates the instance that can generate the chart with the
@@ -166,7 +159,7 @@ class KerykeionChartSVG:
166
159
  self.home_countrycode = self.user.nation
167
160
  self.home_timezonestr = self.user.tz_str
168
161
 
169
- logger.info(f"{self.user.name} birth location: {self.home_location}, {self.home_geolat}, {self.home_geolon}")
162
+ logging.info(f"{self.user.name} birth location: {self.home_location}, {self.home_geolat}, {self.home_geolon}")
170
163
 
171
164
  # default location
172
165
  self.location = self.home_location
@@ -238,7 +231,7 @@ class KerykeionChartSVG:
238
231
  Sets the output direcotry and returns it's path.
239
232
  """
240
233
  self.output_directory = dir_path
241
- logger.info(f"Output direcotry set to: {self.output_directory}")
234
+ logging.info(f"Output direcotry set to: {self.output_directory}")
242
235
 
243
236
  def parse_json_settings(self, settings_file):
244
237
  """
@@ -534,7 +527,7 @@ class KerykeionChartSVG:
534
527
  for i in range(len(self.available_planets_setting)):
535
528
  if self.available_planets_setting[i]["is_active"] == 1:
536
529
  # list of planets sorted by degree
537
- logger.debug(f"planet: {i}, degree: {self.points_deg_ut[i]}")
530
+ logging.debug(f"planet: {i}, degree: {self.points_deg_ut[i]}")
538
531
  planets_degut[self.points_deg_ut[i]] = i
539
532
 
540
533
  self._value_element_from_planet(i)
@@ -566,7 +559,7 @@ class KerykeionChartSVG:
566
559
  diffb = degreeDiff(next, self.points_deg_ut[i])
567
560
  planets_by_pos[e] = [i, diffa, diffb]
568
561
 
569
- logger.debug(f'{self.available_planets_setting[i]["label"]}, {diffa}, {diffb}')
562
+ logging.debug(f'{self.available_planets_setting[i]["label"]}, {diffa}, {diffb}')
570
563
 
571
564
  if diffb < planet_drange:
572
565
  if group_open:
@@ -931,7 +924,7 @@ class KerykeionChartSVG:
931
924
  for l, w in opp[k].items():
932
925
  for a, b in sq.items():
933
926
  if k in sq[a] and l in sq[a]:
934
- logger.debug(f"Got tsquare {a} {k} {l}")
927
+ logging.debug(f"Got tsquare {a} {k} {l}")
935
928
  if k > l:
936
929
  tsquare[f"{a},{l},{k}"] = f"{self.available_planets_setting[a]['label']} => {self.available_planets_setting[l]['label']}, {self.available_planets_setting[k]['label']}"
937
930
 
@@ -1252,7 +1245,7 @@ class KerykeionChartSVG:
1252
1245
 
1253
1246
  return out
1254
1247
 
1255
- def _createTemplateDictionary(self):
1248
+ def _createTemplateDictionary(self) -> ChartTemplateDictionary:
1256
1249
  # self.chart_type = "Transit"
1257
1250
  # empty element points
1258
1251
  self.fire = 0.0
@@ -1280,7 +1273,7 @@ class KerykeionChartSVG:
1280
1273
  viewbox = self.chart_settings["wide_chart_viewBox"]
1281
1274
 
1282
1275
  # template dictionary
1283
- td: ChartTemplateModel = dict()
1276
+ td: ChartTemplateDictionary = dict() # type: ignore
1284
1277
  r = 240
1285
1278
 
1286
1279
  if self.chart_type == "ExternalNatal":
@@ -1474,7 +1467,7 @@ class KerykeionChartSVG:
1474
1467
 
1475
1468
  # return filename
1476
1469
 
1477
- logger.debug(f"Template dictionary keys: {td.keys()}")
1470
+ logging.debug(f"Template dictionary keys: {td.keys()}")
1478
1471
 
1479
1472
  self._createTemplateDictionary()
1480
1473
  return template.replace('"', "'")
@@ -1490,11 +1483,12 @@ class KerykeionChartSVG:
1490
1483
  with open(self.chartname, "w", encoding="utf-8", errors="ignore") as output_file:
1491
1484
  output_file.write(self.template)
1492
1485
 
1493
- logger.info(f"SVG Generated Correctly in: {self.chartname}")
1486
+ logging.info(f"SVG Generated Correctly in: {self.chartname}")
1494
1487
 
1495
1488
 
1496
1489
  if __name__ == "__main__":
1497
- basicConfig(level="DEBUG", force=True)
1490
+ from kerykeion.utilities import setup_logging
1491
+ setup_logging(level="debug")
1498
1492
 
1499
1493
  first = AstrologicalSubject("John Lennon", 1940, 10, 9, 10, 30, "Liverpool", "GB")
1500
1494
  second = AstrologicalSubject("Paul McCartney", 1942, 6, 18, 15, 30, "Liverpool", "GB")
@@ -4,19 +4,12 @@
4
4
  """
5
5
 
6
6
 
7
- from logging import getLogger, basicConfig
7
+ import logging
8
8
  from requests import Request
9
9
  from requests_cache import CachedSession
10
10
  from typing import Union
11
11
 
12
12
 
13
- logger = getLogger(__name__)
14
- basicConfig(
15
- format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
16
- level="INFO"
17
- )
18
-
19
-
20
13
  class FetchGeonames:
21
14
  """
22
15
  Class to handle requests to the GeoNames API
@@ -25,8 +18,6 @@ class FetchGeonames:
25
18
  city_name (str): Name of the city
26
19
  country_code (str): Two letters country code
27
20
  username (str, optional): GeoNames username, defaults to "century.boy".
28
- logger (Union[logging.Logger, None], optional):
29
- Optional logger, defaults to None. If none provided creates one.
30
21
  """
31
22
 
32
23
  def __init__(
@@ -57,21 +48,21 @@ class FetchGeonames:
57
48
  params = {"lat": lat, "lng": lon, "username": self.username}
58
49
 
59
50
  prepared_request = Request("GET", self.timezone_url, params=params).prepare()
60
- logger.debug(f"Requesting data from GeoName timezones: {prepared_request.url}")
51
+ logging.debug(f"Requesting data from GeoName timezones: {prepared_request.url}")
61
52
 
62
53
  try:
63
54
  response = self.session.send(prepared_request)
64
55
  response_json = response.json()
65
56
 
66
57
  except Exception as e:
67
- logger.error(f"Error fetching {self.timezone_url}: {e}")
58
+ logging.error(f"Error fetching {self.timezone_url}: {e}")
68
59
  return {}
69
60
 
70
61
  try:
71
62
  timezone_data["timezonestr"] = response_json["timezoneId"]
72
63
 
73
64
  except Exception as e:
74
- logger.error(f"Error serializing data maybe wrong username? Details: {e}")
65
+ logging.error(f"Error serializing data maybe wrong username? Details: {e}")
75
66
  return {}
76
67
 
77
68
  if hasattr(response, "from_cache"):
@@ -95,14 +86,14 @@ class FetchGeonames:
95
86
  }
96
87
 
97
88
  prepared_request = Request("GET", self.base_url, params=params).prepare()
98
- logger.debug(f"Requesting data from geonames basic: {prepared_request.url}")
89
+ logging.debug(f"Requesting data from geonames basic: {prepared_request.url}")
99
90
 
100
91
  try:
101
92
  response = self.session.send(prepared_request)
102
93
  response_json = response.json()
103
94
 
104
95
  except Exception as e:
105
- logger.error(f"Error in fetching {self.base_url}: {e}")
96
+ logging.error(f"Error in fetching {self.base_url}: {e}")
106
97
  return {}
107
98
 
108
99
  try:
@@ -112,7 +103,7 @@ class FetchGeonames:
112
103
  city_data_whitout_tz["countryCode"] = response_json["geonames"][0]["countryCode"]
113
104
 
114
105
  except Exception as e:
115
- logger.error(f"Error serializing data maybe wrong username? Details: {e}")
106
+ logging.error(f"Error serializing data maybe wrong username? Details: {e}")
116
107
  return {}
117
108
 
118
109
  if hasattr(response, "from_cache"):
@@ -132,18 +123,15 @@ class FetchGeonames:
132
123
  timezone_response = self.__get_timezone(city_data_response["lat"], city_data_response["lng"])
133
124
 
134
125
  except Exception as e:
135
- logger.error(f"Error in fetching timezone: {e}")
126
+ logging.error(f"Error in fetching timezone: {e}")
136
127
  return {}
137
128
 
138
129
  return {**timezone_response, **city_data_response}
139
130
 
140
131
 
141
132
  if __name__ == "__main__":
142
- basicConfig(
143
- format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
144
- level="DEBUG",
145
- force=True,
146
- )
133
+ from kerykeion.utilities import setup_logging
134
+ setup_logging(level="debug")
147
135
 
148
136
  geonames = FetchGeonames("Roma", "IT")
149
137
  print(geonames.get_serialized_data())
@@ -1,5 +1,5 @@
1
1
  from .kerykeion_exception import KerykeionException
2
2
  from .kr_literals import *
3
3
  from .kr_models import *
4
- from .chart_types import ChartTemplateModel
5
- from .settings_models import KerykeionSettingsModel
4
+ from .chart_types import ChartTemplateDictionary
5
+ from .settings_models import KerykeionSettingsModel
@@ -1,16 +1,7 @@
1
- from typing import Literal, Union, Optional
2
- from pydantic import BaseModel
1
+ from typing import TypedDict
3
2
 
4
3
 
5
- class ChartTemplateModel(BaseModel):
6
- """Pydantic model for the chart template."""
7
-
8
- def __setitem__(self, key, value):
9
- setattr(self, key, value)
10
-
11
- def __getitem__(self, key):
12
- return getattr(self, key)
13
-
4
+ class ChartTemplateDictionary(TypedDict):
14
5
  transitRing: str
15
6
  degreeRing: str
16
7
  c1: str
@@ -19,14 +10,14 @@ class ChartTemplateModel(BaseModel):
19
10
  c2style: str
20
11
  c3: str
21
12
  c3style: str
22
- makeAspects: bool
23
- makeAspectGrid: bool
24
- makePatterns: bool
25
- chart_width: int
26
- circleX: int
27
- circleY: int
28
- svgWidth: int
29
- svgHeight: int
13
+ makeAspects: str
14
+ makeAspectGrid: str
15
+ makePatterns: str
16
+ chart_width: float
17
+ circleX: str
18
+ circleY: str
19
+ svgWidth: str
20
+ svgHeight: str
30
21
  viewbox: str
31
22
  stringTitle: str
32
23
  stringName: str
@@ -39,7 +30,7 @@ class ChartTemplateModel(BaseModel):
39
30
  lunar_phase_cx: int
40
31
  lunar_phase_r: int
41
32
  lunar_phase_outline: str
42
- lunar_phase_rotate: int
33
+ lunar_phase_rotate: float
43
34
  stringLocation: str
44
35
  stringDateTime: str
45
36
  stringLat: str
@@ -86,12 +77,12 @@ class ChartTemplateModel(BaseModel):
86
77
  orb_color_144: str
87
78
  orb_color_150: str
88
79
  orb_color_180: str
89
- cfgZoom: float
90
- cfgRotate: int
80
+ cfgZoom: str
81
+ cfgRotate: str
91
82
  cfgTranslate: str
92
- makeZodiac: bool
93
- makeHouses: bool
94
- makePlanets: bool
95
- makeElements: bool
96
- makePlanetGrid: bool
97
- makeHousesGrid: bool
83
+ makeZodiac: str
84
+ makeHouses: str
85
+ makePlanets: str
86
+ makeElements: str
87
+ makePlanetGrid: str
88
+ makeHousesGrid: str
@@ -11,7 +11,7 @@ from .kr_literals import *
11
11
 
12
12
 
13
13
  class LunarPhaseModel(BaseModel):
14
- degrees_between_s_m: Union[int, float]
14
+ degrees_between_s_m: Union[float, int]
15
15
  moon_phase: int
16
16
  sun_phase: int
17
17
  moon_emoji: LunarPhaseEmoji
@@ -31,7 +31,7 @@ class LunarPhaseModel(BaseModel):
31
31
  def __repr__(self):
32
32
  return (
33
33
  super()
34
- .dict(
34
+ .model_dump(
35
35
  exclude_none=True,
36
36
  exclude_unset=True,
37
37
  exclude_defaults=True,
@@ -136,6 +136,7 @@ class AstrologicalSubjectModel(BaseModel):
136
136
  uranus: KerykeionPointModel
137
137
  neptune: KerykeionPointModel
138
138
  pluto: KerykeionPointModel
139
+ chiron: KerykeionPointModel
139
140
 
140
141
  # Houses
141
142
  first_house: KerykeionPointModel
@@ -160,6 +161,9 @@ class AstrologicalSubjectModel(BaseModel):
160
161
 
161
162
 
162
163
  if __name__ == "__main__":
164
+ from kerykeion.utilities import setup_logging
165
+ setup_logging(level="debug")
166
+
163
167
  sun = KerykeionPointModel(
164
168
  name="Sun",
165
169
  element="Air",
@@ -5,16 +5,11 @@
5
5
 
6
6
 
7
7
  from json import load
8
- from logging import getLogger, basicConfig
9
8
  from pydantic import BaseModel, Field
10
9
  from pathlib import Path
11
10
  from typing import Dict, List, Union
12
11
 
13
12
 
14
- logger = getLogger(__name__)
15
- basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level="INFO")
16
-
17
-
18
13
  class CustomBaseModel(BaseModel):
19
14
  """
20
15
  Extends the BaseModel class of Pydantic to add some useful methods.
@@ -5,18 +5,11 @@
5
5
 
6
6
  from kerykeion import AstrologicalSubject
7
7
  from kerykeion.aspects.synastry_aspects import SynastryAspects
8
- from logging import basicConfig, getLogger
8
+ import logging
9
9
  from pathlib import Path
10
10
  from typing import Union
11
11
 
12
12
 
13
- logger = getLogger(__name__)
14
- basicConfig(
15
- format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
16
- level="INFO"
17
- )
18
-
19
-
20
13
  class RelationshipScore:
21
14
  """
22
15
  Calculates the relevance of the relationship of the two subjects according to
@@ -78,7 +71,7 @@ class RelationshipScore:
78
71
  }
79
72
 
80
73
  def _log_aspect(self, aspect: dict, points: int) -> None:
81
- logger.debug(
74
+ logging.debug(
82
75
  f"{points} Points: {aspect['p1_name']} {aspect['aspect']} {aspect['p2_name']}, rounded orbit: {int(aspect['orbit'])}"
83
76
  )
84
77
 
@@ -87,7 +80,7 @@ class RelationshipScore:
87
80
  5 points if is a destiny sign:
88
81
  """
89
82
  if self.first_subject.sun["quality"] == self.second_subject.sun["quality"]:
90
- logger.debug(
83
+ logging.debug(
91
84
  f'5 points: Destiny sign, {self.first_subject.sun["sign"]} and {self.second_subject.sun["sign"]}'
92
85
  )
93
86
  self.is_destiny_sign = True
@@ -200,7 +193,8 @@ class RelationshipScore:
200
193
 
201
194
 
202
195
  if __name__ == "__main__":
203
- basicConfig(level="DEBUG", force=True)
196
+ from kerykeion.utilities import setup_logging
197
+ setup_logging(level="debug")
204
198
 
205
199
  lui = AstrologicalSubject("John", 1975, 10, 10, 21, 15, "Roma", "IT")
206
200
  lei = AstrologicalSubject("Sarah", 1978, 2, 9, 15, 50, "Roma", "IT")
@@ -83,6 +83,9 @@ class Report:
83
83
 
84
84
 
85
85
  if __name__ == "__main__":
86
+ from kerykeion.utilities import setup_logging
87
+ setup_logging(level="debug")
88
+
86
89
  john = AstrologicalSubject("John", 1975, 10, 10, 21, 15, "Roma", "IT")
87
90
  report = Report(john)
88
91
  report.print_report()
@@ -5,18 +5,12 @@
5
5
 
6
6
 
7
7
  from json import load
8
- from logging import getLogger, basicConfig
8
+ import logging
9
9
  from pathlib import Path
10
10
  from typing import Dict, Union
11
11
  from kerykeion.kr_types import KerykeionSettingsModel
12
12
 
13
13
 
14
- logger = getLogger(__name__)
15
- basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level="INFO")
16
-
17
-
18
-
19
-
20
14
  def get_settings(new_settings_file: Union[Path, None] = None) -> KerykeionSettingsModel:
21
15
  """
22
16
  This function is used to get the settings dict from the settings file.
@@ -47,7 +41,7 @@ def get_settings(new_settings_file: Union[Path, None] = None) -> KerykeionSettin
47
41
  if not settings_file.exists():
48
42
  settings_file = Path(__file__).parent / "kr.config.json"
49
43
 
50
- logger.debug(f"Kerykeion config file path: {settings_file}")
44
+ logging.debug(f"Kerykeion config file path: {settings_file}")
51
45
  with open(settings_file, "r", encoding="utf8") as f:
52
46
  settings_dict = load(f)
53
47
 
@@ -71,4 +65,7 @@ def merge_settings(settings: KerykeionSettingsModel, new_settings: Dict) -> Kery
71
65
 
72
66
 
73
67
  if __name__ == "__main__":
68
+ from kerykeion.utilities import setup_logging
69
+ setup_logging(level="debug")
70
+
74
71
  print(get_settings())
@@ -1,8 +1,6 @@
1
1
  from kerykeion.kr_types import KerykeionPointModel, KerykeionException, KerykeionSettingsModel, AstrologicalSubjectModel
2
2
  from typing import Union, Literal
3
- from logging import getLogger
4
-
5
- logger = getLogger(__name__)
3
+ import logging
6
4
 
7
5
 
8
6
  def get_number_from_name(name: str) -> int:
@@ -203,4 +201,17 @@ def calculate_position(
203
201
  else:
204
202
  raise KerykeionException(f"Error in calculating positions! Degrees: {degree}")
205
203
 
206
- return KerykeionPointModel(**dictionary)
204
+ return KerykeionPointModel(**dictionary)
205
+
206
+ def setup_logging(level: str) -> None:
207
+ """Setup logging for testing.
208
+
209
+ Args:
210
+ level: Log level as a string, options: debug, info, warning, error"""
211
+ logopt: dict[str, int] = {"debug": logging.DEBUG,
212
+ "info": logging.INFO,
213
+ "warning": logging.WARNING ,
214
+ "error": logging.ERROR}
215
+ format: str = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
216
+ loglevel: int = logopt.get(level, logging.INFO)
217
+ logging.basicConfig(format=format, level=loglevel)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "kerykeion"
3
- version = "4.2.3"
3
+ version = "4.3.0"
4
4
  authors = ["Giacomo Battaglia <battaglia.giacomo@yahoo.it>"]
5
5
  description = "A python library for astrology."
6
6
  license = "AGPL-3.0"
@@ -46,7 +46,7 @@ pyswisseph = "^2.10.3.1"
46
46
  pytz = "^2022.7"
47
47
  requests = "^2.28.1"
48
48
  requests-cache = "^0.9.7"
49
- pydantic = "^1.10.4"
49
+ pydantic = "^2.5"
50
50
  terminaltables = "^3.1.10"
51
51
 
52
52
  [tool.poetry.scripts]
File without changes
File without changes