kerykeion 4.0.6__py3-none-any.whl → 4.12.3__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.

Potentially problematic release.


This version of kerykeion might be problematic. Click here for more details.

kerykeion/enums.py ADDED
@@ -0,0 +1,50 @@
1
+ from enum import Enum
2
+
3
+
4
+ class Planets(Enum):
5
+ SUN = "Sun"
6
+ MOON = "Moon"
7
+ MERCURY = "Mercury"
8
+ VENUS = "Venus"
9
+ MARS = "Mars"
10
+ JUPITER = "Jupiter"
11
+ SATURN = "Saturn"
12
+ URANUS = "Uranus"
13
+ NEPTUNE = "Neptune"
14
+ PLUTO = "Pluto"
15
+ CHIRON = "Chiron"
16
+ TRUE_NODE = "True_Node"
17
+ MEAN_NODE = "Mean_Node"
18
+
19
+
20
+ class Aspects(Enum):
21
+ CONJUNCTION = "Conjunction"
22
+ SEXTILE = "Sextile"
23
+ SEMI_SEXTILE = "Semi-Sextile"
24
+ SQUARE = "Square"
25
+ TRINE = "Trine"
26
+ OPPOSITION = "Opposition"
27
+ QUINCUNX = "Quincunx"
28
+ NONE = None
29
+ QUINTILE = "Quintile"
30
+ BIQUINTILE = "Biquintile"
31
+ OCTILE = "Octile"
32
+ TRIOCTILE = "Trioctile"
33
+ DECILE = "Decile"
34
+ TRIDECILE = "Tridecile"
35
+ SESQUIQUADRATE = "Sesquiquadrate"
36
+
37
+
38
+ class Signs(Enum):
39
+ ARI = "Ari"
40
+ TAU = "Tau"
41
+ GEM = "Gem"
42
+ CAN = "Can"
43
+ LEO = "Leo"
44
+ VIR = "Vir"
45
+ LIB = "Lib"
46
+ SCO = "Sco"
47
+ SAG = "Sag"
48
+ CAP = "Cap"
49
+ AQU = "Aqu"
50
+ PIS = "Pis"
@@ -1,22 +1,15 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  """
3
- This is part of Kerykeion (C) 2023 Giacomo Battaglia
3
+ This is part of Kerykeion (C) 2024 Giacomo Battaglia
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"):
@@ -91,18 +82,21 @@ class FetchGeonames:
91
82
  "contry": country_code,
92
83
  "username": self.username,
93
84
  "maxRows": 1,
94
- "style": "FULL",
85
+ "style": "SHORT",
86
+ "featureClass": "A",
87
+ "featureClass": "P",
95
88
  }
96
89
 
97
90
  prepared_request = Request("GET", self.base_url, params=params).prepare()
98
- logger.debug(f"Requesting data from geonames basic: {prepared_request.url}")
91
+ logging.debug(f"Requesting data from geonames basic: {prepared_request.url}")
99
92
 
100
93
  try:
101
94
  response = self.session.send(prepared_request)
102
95
  response_json = response.json()
96
+ logging.debug(f"Response from GeoNames: {response_json}")
103
97
 
104
98
  except Exception as e:
105
- logger.error(f"Error in fetching {self.base_url}: {e}")
99
+ logging.error(f"Error in fetching {self.base_url}: {e}")
106
100
  return {}
107
101
 
108
102
  try:
@@ -112,7 +106,7 @@ class FetchGeonames:
112
106
  city_data_whitout_tz["countryCode"] = response_json["geonames"][0]["countryCode"]
113
107
 
114
108
  except Exception as e:
115
- logger.error(f"Error serializing data maybe wrong username? Details: {e}")
109
+ logging.error(f"Error serializing data maybe wrong username? Details: {e}")
116
110
  return {}
117
111
 
118
112
  if hasattr(response, "from_cache"):
@@ -132,18 +126,15 @@ class FetchGeonames:
132
126
  timezone_response = self.__get_timezone(city_data_response["lat"], city_data_response["lng"])
133
127
 
134
128
  except Exception as e:
135
- logger.error(f"Error in fetching timezone: {e}")
129
+ logging.error(f"Error in fetching timezone: {e}")
136
130
  return {}
137
131
 
138
132
  return {**timezone_response, **city_data_response}
139
133
 
140
134
 
141
135
  if __name__ == "__main__":
142
- basicConfig(
143
- format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
144
- level="DEBUG",
145
- force=True,
146
- )
136
+ from kerykeion.utilities import setup_logging
137
+ setup_logging(level="debug")
147
138
 
148
- geonames = FetchGeonames("Roma", "IT")
139
+ geonames = FetchGeonames("Montichiari", "IT")
149
140
  print(geonames.get_serialized_data())
@@ -1,3 +1,10 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ This is part of Kerykeion (C) 2024 Giacomo Battaglia
4
+ """
5
+
1
6
  from .kerykeion_exception import KerykeionException
2
7
  from .kr_literals import *
3
8
  from .kr_models import *
9
+ from .chart_types import ChartTemplateDictionary
10
+ from .settings_models import KerykeionSettingsModel
@@ -1,35 +1,26 @@
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
- c1: str
17
- c1style: str
18
- c2: str
19
- c2style: str
7
+ first_circle: str
8
+ second_circle: str
20
9
  c3: str
21
10
  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
11
+ makeAspects: str
12
+ makeAspectGrid: str
13
+ makePatterns: str
14
+ chart_height: float
15
+ chart_width: float
16
+ circleX: str
17
+ circleY: str
18
+ svgWidth: str
19
+ svgHeight: str
30
20
  viewbox: str
31
21
  stringTitle: str
32
22
  stringName: str
23
+ bottomLeft0: str
33
24
  bottomLeft1: str
34
25
  bottomLeft2: str
35
26
  bottomLeft3: str
@@ -39,14 +30,19 @@ 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
46
37
  stringLon: str
47
38
  stringPosition: str
39
+
40
+ # Font color
48
41
  paper_color_0: str
42
+ # Background color of the chart
49
43
  paper_color_1: str
44
+
45
+ # Planets colors, from 1 to 15 (0 is the Sun)
50
46
  planets_color_0: str
51
47
  planets_color_1: str
52
48
  planets_color_2: str
@@ -63,6 +59,8 @@ class ChartTemplateModel(BaseModel):
63
59
  planets_color_13: str
64
60
  planets_color_14: str
65
61
  planets_color_15: str
62
+
63
+ # Zodiac colors, from 0 to 11 (0 is Aries)
66
64
  zodiac_color_0: str
67
65
  zodiac_color_1: str
68
66
  zodiac_color_2: str
@@ -75,6 +73,8 @@ class ChartTemplateModel(BaseModel):
75
73
  zodiac_color_9: str
76
74
  zodiac_color_10: str
77
75
  zodiac_color_11: str
76
+
77
+ # Aspects colors, from 0 to 9 (0 is conjunction)
78
78
  orb_color_0: str
79
79
  orb_color_30: str
80
80
  orb_color_45: str
@@ -86,12 +86,13 @@ class ChartTemplateModel(BaseModel):
86
86
  orb_color_144: str
87
87
  orb_color_150: str
88
88
  orb_color_180: str
89
- cfgZoom: float
90
- cfgRotate: int
89
+
90
+ cfgZoom: str
91
+ cfgRotate: str
91
92
  cfgTranslate: str
92
- makeZodiac: bool
93
- makeHouses: bool
94
- makePlanets: bool
95
- makeElements: bool
96
- makePlanetGrid: bool
97
- makeHousesGrid: bool
93
+ makeZodiac: str
94
+ makeHouses: str
95
+ makePlanets: str
96
+ elements_percentages: str
97
+ makePlanetGrid: str
98
+ makeHousesGrid: str
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  """
3
- This is part of Kerykeion (C) 2023 Giacomo Battaglia
3
+ This is part of Kerykeion (C) 2024 Giacomo Battaglia
4
4
  """
5
5
 
6
6
 
@@ -1,58 +1,101 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  """
3
- This is part of Kerykeion (C) 2023 Giacomo Battaglia
3
+ This is part of Kerykeion (C) 2024 Giacomo Battaglia
4
4
  """
5
-
6
-
7
5
  from typing import Literal
8
6
 
9
- # Zodiac Types:
7
+
10
8
  ZodiacType = Literal["Tropic", "Sidereal"]
9
+ """Literal type for Zodiac Types"""
10
+
11
+
12
+ Sign = Literal["Ari", "Tau", "Gem", "Can", "Leo", "Vir", "Lib", "Sco", "Sag", "Cap", "Aqu", "Pis"]
13
+ """Literal type for Zodiac Signs"""
14
+
15
+
16
+ SignNumbers = Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
17
+ """Literal type for Zodiac Sign Numbers, the signs are numbered in order starting from Aries (0) to Pisces (11)"""
18
+
19
+
20
+ Houses = Literal["First_House", "Second_House", "Third_House", "Fourth_House", "Fifth_House", "Sixth_House", "Seventh_House", "Eighth_House", "Ninth_House", "Tenth_House", "Eleventh_House", "Twelfth_House"]
21
+ """Literal type for Houses"""
22
+
23
+
24
+ HouseNumbers = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
25
+ """Literal type for House Numbers, starting from the First House (1) to the Twelfth House (12)"""
26
+
27
+
28
+ Planet = Literal["Sun", "Moon", "Mercury", "Venus", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto", "Mean_Node", "True_Node", "Chiron"]
29
+ """Literal type for Planets"""
11
30
 
12
- # Sings:
13
- Sign = Literal[
14
- "Ari", "Tau", "Gem", "Can", "Leo", "Vir", "Lib", "Sco", "Sag", "Cap", "Aqu", "Pis"
15
- ]
16
-
17
- Houses = Literal[
18
- "First_House",
19
- "Second_House",
20
- "Third_House",
21
- "Fourth_House",
22
- "Fifth_House",
23
- "Sixth_House",
24
- "Seventh_House",
25
- "Eighth_House",
26
- "Ninth_House",
27
- "Tenth_House",
28
- "Eleventh_House",
29
- "Twelfth_House",
30
- ]
31
-
32
- Planet = Literal[
33
- "Sun",
34
- "Moon",
35
- "Mercury",
36
- "Venus",
37
- "Mars",
38
- "Jupiter",
39
- "Saturn",
40
- "Uranus",
41
- "Neptune",
42
- "Pluto",
43
- "Mean_Node",
44
- "True_Node",
45
- "Chiron",
46
- ]
47
31
 
48
32
  Element = Literal["Air", "Fire", "Earth", "Water"]
33
+ """Literal type for Elements"""
34
+
35
+
36
+ Quality = Literal["Cardinal", "Fixed", "Mutable"]
37
+ """Literal type for Qualities"""
49
38
 
50
- Quality = Literal[
51
- "Cardinal",
52
- "Fixed",
53
- "Mutable",
54
- ]
55
39
 
56
40
  ChartType = Literal["Natal", "ExternalNatal", "Synastry", "Transit"]
41
+ """Literal type for Chart Types"""
42
+
43
+
44
+ PointType = Literal["Planet", "House"]
45
+ """Literal type for Point Types"""
46
+
57
47
 
58
48
  LunarPhaseEmoji = Literal["🌑", "🌒", "🌓", "🌔", "🌕", "🌖", "🌗", "🌘"]
49
+ """Literal type for Lunar Phases Emoji"""
50
+
51
+
52
+ LunarPhaseName = Literal["New Moon", "Waxing Crescent", "First Quarter", "Waxing Gibbous", "Full Moon", "Waning Gibbous", "Last Quarter", "Waning Crescent"]
53
+ """Literal type for Lunar Phases Name"""
54
+
55
+
56
+ SiderealMode = Literal["FAGAN_BRADLEY", "LAHIRI", "DELUCE", "RAMAN", "USHASHASHI", "KRISHNAMURTI", "DJWHAL_KHUL", "YUKTESHWAR", "JN_BHASIN", "BABYL_KUGLER1", "BABYL_KUGLER2", "BABYL_KUGLER3", "BABYL_HUBER", "BABYL_ETPSC", "ALDEBARAN_15TAU", "HIPPARCHOS", "SASSANIAN", "J2000", "J1900", "B1950"]
57
+ """Literal type for Sidereal Modes, as known as Ayanamsa"""
58
+
59
+
60
+ HousesSystemIdentifier = Literal["A", "B", "C", "D", "F", "H", "I", "i", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y"]
61
+ """
62
+ Literal type for Houses Systems:
63
+
64
+ A = equal
65
+ B = Alcabitius
66
+ C = Campanus
67
+ D = equal (MC)
68
+ F = Carter poli-equ.
69
+ H = horizon/azimut
70
+ I = Sunshine
71
+ i = Sunshine/alt.
72
+ K = Koch
73
+ L = Pullen SD
74
+ M = Morinus
75
+ N = equal/1=Aries
76
+ O = Porphyry
77
+ P = Placidus
78
+ Q = Pullen SR
79
+ R = Regiomontanus
80
+ S = Sripati
81
+ T = Polich/Page
82
+ U = Krusinski-Pisa-Goelzer
83
+ V = equal/Vehlow
84
+ W = equal/whole sign
85
+ X = axial rotation system/Meridian houses
86
+ Y = APC houses
87
+
88
+ Usually the standard is Placidus (P)
89
+ """
90
+
91
+
92
+ PerspectiveType = Literal["Apparent Geocentric", "Heliocentric", "Topocentric", "True Geocentric"]
93
+ """
94
+ Literal type for perspective types.
95
+ - "Apparent Geocentric": Earth-centered, apparent positions.
96
+ - "Heliocentric": Sun-centered.
97
+ - "Topocentric": Observer's location on Earth's surface.
98
+ - "True Geocentric": Earth-centered, true positions.
99
+
100
+ Usually the standard is "Apparent Geocentric"
101
+ """
@@ -1,45 +1,18 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  """
3
- This is part of Kerykeion (C) 2023 Giacomo Battaglia
3
+ This is part of Kerykeion (C) 2024 Giacomo Battaglia
4
4
  """
5
5
 
6
6
 
7
- from typing import Literal, Union, Optional
7
+ from typing import Union, Optional
8
8
  from pydantic import BaseModel
9
9
 
10
- from .kr_literals import *
11
-
12
-
13
- class LunarPhaseModel(BaseModel):
14
- degrees_between_s_m: Union[int, float]
15
- moon_phase: int
16
- sun_phase: int
17
- moon_emoji: LunarPhaseEmoji
18
-
19
- def __str__(self):
20
- return (
21
- super()
22
- .dict(
23
- exclude_none=True,
24
- exclude_unset=True,
25
- exclude_defaults=True,
26
- by_alias=False,
27
- )
28
- .__str__()
29
- )
30
-
31
- def __repr__(self):
32
- return (
33
- super()
34
- .dict(
35
- exclude_none=True,
36
- exclude_unset=True,
37
- exclude_defaults=True,
38
- by_alias=False,
39
- )
40
- .__str__()
41
- )
10
+ from kerykeion.kr_types import LunarPhaseEmoji, LunarPhaseName, Planet, Houses, Quality, Element, Sign, ZodiacType, SignNumbers, HouseNumbers, PointType, SiderealMode, HousesSystemIdentifier
42
11
 
12
+ class SubscriptableBaseModel(BaseModel):
13
+ """
14
+ Pydantic BaseModel with subscriptable support, so you can access the fields as if they were a dictionary.
15
+ """
43
16
  def __getitem__(self, key):
44
17
  return getattr(self, key)
45
18
 
@@ -52,8 +25,15 @@ class LunarPhaseModel(BaseModel):
52
25
  def get(self, key, default):
53
26
  return getattr(self, key, default)
54
27
 
28
+ class LunarPhaseModel(SubscriptableBaseModel):
29
+ degrees_between_s_m: Union[float, int]
30
+ moon_phase: int
31
+ sun_phase: int
32
+ moon_emoji: LunarPhaseEmoji
33
+ moon_phase_name: LunarPhaseName
55
34
 
56
- class KerykeionPointModel(BaseModel):
35
+
36
+ class KerykeionPointModel(SubscriptableBaseModel):
57
37
  """
58
38
  Kerykeion Point Model
59
39
  """
@@ -62,52 +42,16 @@ class KerykeionPointModel(BaseModel):
62
42
  quality: Quality
63
43
  element: Element
64
44
  sign: Sign
65
- sign_num: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
45
+ sign_num: SignNumbers
66
46
  position: float
67
47
  abs_pos: float
68
48
  emoji: str
69
- point_type: Literal["Planet", "House"]
70
- house: Optional[Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]] = None
49
+ point_type: PointType
50
+ house: Optional[HouseNumbers] = None
71
51
  retrograde: Optional[bool] = None
72
52
 
73
- def __str__(self):
74
- return (
75
- super()
76
- .dict(
77
- exclude_none=True,
78
- exclude_unset=True,
79
- exclude_defaults=True,
80
- by_alias=False,
81
- )
82
- .__str__()
83
- )
84
-
85
- def __repr__(self):
86
- return (
87
- super()
88
- .dict(
89
- exclude_none=True,
90
- exclude_unset=True,
91
- exclude_defaults=True,
92
- by_alias=False,
93
- )
94
- .__str__()
95
- )
96
-
97
- def __getitem__(self, key):
98
- return getattr(self, key)
99
53
 
100
- def __setitem__(self, key, value):
101
- setattr(self, key, value)
102
-
103
- def __delitem__(self, key):
104
- delattr(self, key)
105
-
106
- def get(self, key, default):
107
- return getattr(self, key, default)
108
-
109
-
110
- class AstrologicalSubjectModel(BaseModel):
54
+ class AstrologicalSubjectModel(SubscriptableBaseModel):
111
55
  # Data
112
56
  name: str
113
57
  year: int
@@ -121,8 +65,12 @@ class AstrologicalSubjectModel(BaseModel):
121
65
  lat: float
122
66
  tz_str: str
123
67
  zodiac_type: ZodiacType
124
- local_time: float
125
- utc_time: float
68
+ sidereal_mode: Union[SiderealMode, None]
69
+ houses_system_identifier: HousesSystemIdentifier
70
+ houses_system_name: str
71
+ perspective_type: str
72
+ iso_formatted_local_datetime: str
73
+ iso_formatted_utc_datetime: str
126
74
  julian_day: float
127
75
 
128
76
  # Planets
@@ -137,6 +85,9 @@ class AstrologicalSubjectModel(BaseModel):
137
85
  neptune: KerykeionPointModel
138
86
  pluto: KerykeionPointModel
139
87
 
88
+ # Optional Planets:
89
+ chiron: Union[KerykeionPointModel, None]
90
+
140
91
  # Houses
141
92
  first_house: KerykeionPointModel
142
93
  second_house: KerykeionPointModel
@@ -158,8 +109,21 @@ class AstrologicalSubjectModel(BaseModel):
158
109
  # Lunar Phase
159
110
  lunar_phase: LunarPhaseModel
160
111
 
112
+ # Deprecated properties
113
+ utc_time: float
114
+ local_time: float
115
+
116
+ # Lists
117
+ # houses_list: list[KerykeionPointModel]
118
+ # planets_list: list[KerykeionPointModel]
119
+ # planets_degrees_ut: list[float]
120
+ # houses_degree_ut: list[float]
161
121
 
162
122
  if __name__ == "__main__":
123
+ from kerykeion.utilities import setup_logging
124
+
125
+ setup_logging(level="debug")
126
+
163
127
  sun = KerykeionPointModel(
164
128
  name="Sun",
165
129
  element="Air",
@@ -172,5 +136,5 @@ if __name__ == "__main__":
172
136
  point_type="Planet",
173
137
  )
174
138
 
175
- print(sun.json())
139
+ print(sun.model_dump_json())
176
140
  print(sun)