kerykeion 4.7.0__tar.gz → 4.8.1__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 (30) hide show
  1. {kerykeion-4.7.0 → kerykeion-4.8.1}/PKG-INFO +2 -1
  2. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/astrological_subject.py +5 -5
  3. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/charts/charts_utils.py +48 -1
  4. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/charts/kerykeion_chart_svg.py +42 -40
  5. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/charts/templates/chart.xml +3 -3
  6. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/fetch_geonames.py +5 -2
  7. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/kr_types/chart_types.py +3 -4
  8. {kerykeion-4.7.0 → kerykeion-4.8.1}/pyproject.toml +2 -1
  9. {kerykeion-4.7.0 → kerykeion-4.8.1}/LICENSE +0 -0
  10. {kerykeion-4.7.0 → kerykeion-4.8.1}/README.md +0 -0
  11. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/__init__.py +0 -0
  12. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/aspects/__init__.py +0 -0
  13. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/aspects/aspects_utils.py +0 -0
  14. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/aspects/natal_aspects.py +0 -0
  15. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/aspects/synastry_aspects.py +0 -0
  16. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/charts/__init__.py +0 -0
  17. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/enums.py +0 -0
  18. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/kr_types/__init__.py +0 -0
  19. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/kr_types/kerykeion_exception.py +0 -0
  20. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/kr_types/kr_literals.py +0 -0
  21. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/kr_types/kr_models.py +0 -0
  22. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/kr_types/settings_models.py +0 -0
  23. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/relationship_score.py +0 -0
  24. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/report.py +0 -0
  25. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/settings/__init__.py +0 -0
  26. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/settings/kerykeion_settings.py +0 -0
  27. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/settings/kr.config.json +0 -0
  28. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/sweph/README.md +0 -0
  29. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/sweph/seas_18.se1 +0 -0
  30. {kerykeion-4.7.0 → kerykeion-4.8.1}/kerykeion/utilities.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kerykeion
3
- Version: 4.7.0
3
+ Version: 4.8.1
4
4
  Summary: A python library for astrology.
5
5
  Home-page: https://github.com/g-battaglia/kerykeion
6
6
  License: AGPL-3.0
@@ -30,6 +30,7 @@ Requires-Dist: pyswisseph (>=2.10.3.1,<3.0.0.0)
30
30
  Requires-Dist: pytz (>=2022.7,<2023.0)
31
31
  Requires-Dist: requests (>=2.28.1,<3.0.0)
32
32
  Requires-Dist: requests-cache (>=0.9.7,<0.10.0)
33
+ Requires-Dist: scour (>=0.38.2,<0.39.0)
33
34
  Requires-Dist: terminaltables (>=3.1.10,<4.0.0)
34
35
  Project-URL: Repository, https://github.com/g-battaglia/kerykeion
35
36
  Description-Content-Type: text/markdown
@@ -170,7 +170,7 @@ class AstrologicalSubject:
170
170
 
171
171
  # This message is set to encourage the user to set a custom geonames username
172
172
  if geonames_username is None and online:
173
- logging.info(
173
+ logging.warning(
174
174
  "\n"
175
175
  "********" +
176
176
  "\n" +
@@ -191,19 +191,19 @@ class AstrologicalSubject:
191
191
 
192
192
  if not self.city:
193
193
  self.city = "London"
194
- logging.warning("No city specified, using London as default")
194
+ logging.info("No city specified, using London as default")
195
195
 
196
196
  if not self.nation:
197
197
  self.nation = "GB"
198
- logging.warning("No nation specified, using GB as default")
198
+ logging.info("No nation specified, using GB as default")
199
199
 
200
200
  if not self.lat:
201
201
  self.lat = 51.5074
202
- logging.warning("No latitude specified, using London as default")
202
+ logging.info("No latitude specified, using London as default")
203
203
 
204
204
  if not self.lng:
205
205
  self.lng = 0
206
- logging.warning("No longitude specified, using London as default")
206
+ logging.info("No longitude specified, using London as default")
207
207
 
208
208
  if (not self.online) and (not tz_str):
209
209
  raise KerykeionException(
@@ -394,4 +394,51 @@ def draw_transit_ring(r: Union[int, float], paper_1_color: str, zodiac_transit_r
394
394
  out = f'<circle cx="{r}" cy="{r}" r="{r - radius_offset}" style="fill: none; stroke: {paper_1_color}; stroke-width: 36px; stroke-opacity: .4;"/>'
395
395
  out += f'<circle cx="{r}" cy="{r}" r="{r}" style="fill: none; stroke: {zodiac_transit_ring_3_color}; stroke-width: 1px; stroke-opacity: .6;"/>'
396
396
 
397
- return out
397
+ return out
398
+
399
+
400
+ def draw_first_circle(r: Union[int, float], stroke_color: str, chart_type: ChartType, c1: Union[int, float, None] = None) -> str:
401
+ """
402
+ Draws the first circle.
403
+
404
+ Args:
405
+ - r (Union[int, float]): The value of r.
406
+ - color (str): The color of the circle.
407
+ - chart_type (ChartType): The type of chart.
408
+ - c1 (Union[int, float]): The value of c1.
409
+
410
+ Returns:
411
+ str: The SVG path of the first circle.
412
+ """
413
+ if chart_type == "Synastry" or chart_type == "Transit":
414
+ return f'<circle cx="{r}" cy="{r}" r="{r - 36}" style="fill: none; stroke: {stroke_color}; stroke-width: 1px; stroke-opacity:.4;" />'
415
+ else:
416
+ if c1 is None:
417
+ raise KerykeionException("c1 is None")
418
+
419
+ return f'<circle cx="{r}" cy="{r}" r="{r - c1}" style="fill: none; stroke: {stroke_color}; stroke-width: 1px; " />'
420
+
421
+
422
+ def draw_second_circle(r: Union[int, float], stroke_color: str, fill_color: str, chart_type: ChartType, c2: Union[int, float, None] = None) -> str:
423
+ """
424
+ Draws the second circle.
425
+
426
+ Args:
427
+ - r (Union[int, float]): The value of r.
428
+ - stroke_color (str): The color of the stroke.
429
+ - fill_color (str): The color of the fill.
430
+ - chart_type (ChartType): The type of chart.
431
+ - c2 (Union[int, float]): The value of c2.
432
+
433
+ Returns:
434
+ str: The SVG path of the second circle.
435
+ """
436
+
437
+ if chart_type == "Synastry" or chart_type == "Transit":
438
+ return f'<circle cx="{r}" cy="{r}" r="{r - 72}" style="fill: {fill_color}; fill-opacity:.4; stroke: {stroke_color}; stroke-opacity:.4; stroke-width: 1px" />'
439
+
440
+ else:
441
+ if c2 is None:
442
+ raise KerykeionException("c2 is None")
443
+
444
+ return f'<circle cx="{r}" cy="{r}" r="{r - c2}" style="fill: {fill_color}; fill-opacity:.2; stroke: {stroke_color}; stroke-opacity:.4; stroke-width: 1px" />'
@@ -25,13 +25,17 @@ from kerykeion.charts.charts_utils import (
25
25
  convert_decimal_to_degree_string,
26
26
  draw_transit_ring_degree_steps,
27
27
  draw_degree_ring,
28
- draw_transit_ring
28
+ draw_transit_ring,
29
+ draw_first_circle,
30
+ draw_second_circle
29
31
  )
30
32
  from pathlib import Path
33
+ from scour.scour import scourString
31
34
  from string import Template
32
35
  from typing import Union, List
33
36
 
34
37
 
38
+
35
39
  class KerykeionChartSVG:
36
40
  """
37
41
  Creates the instance that can generate the chart with the
@@ -45,6 +49,11 @@ class KerykeionChartSVG:
45
49
  - lang: language settings (default: "EN")
46
50
  - new_settings_file: Set the settings file (default: kr.config.json)
47
51
  """
52
+
53
+ # Constants
54
+ _DEFAULT_HEIGHT = 546.0
55
+ _DEFAULT_FULL_WIDTH = 1200
56
+ _DEFAULT_NATAL_WIDTH = 772.2
48
57
 
49
58
  # Set at init
50
59
  first_obj: AstrologicalSubject
@@ -64,8 +73,7 @@ class KerykeionChartSVG:
64
73
  c3: float
65
74
  homedir: Path
66
75
  xml_svg: Path
67
- natal_width: float
68
- full_width: float
76
+ width: Union[float, int]
69
77
  language_settings: dict
70
78
  chart_colors_settings: dict
71
79
  planets_settings: dict
@@ -85,8 +93,7 @@ class KerykeionChartSVG:
85
93
  t_points_sign: list
86
94
  t_points_retrograde: list
87
95
  t_houses_sign_graph: list
88
- screen_width: float
89
- screen_height: float
96
+ height: float
90
97
  location: str
91
98
  geolat: float
92
99
  geolon: float
@@ -114,10 +121,6 @@ class KerykeionChartSVG:
114
121
 
115
122
  self.xml_svg = DATA_DIR / "templates/chart.xml"
116
123
 
117
- # SVG Width
118
- self.natal_width = 772.2
119
- self.full_width = 1200
120
-
121
124
  self.parse_json_settings(new_settings_file)
122
125
  self.chart_type = chart_type
123
126
 
@@ -215,11 +218,12 @@ class KerykeionChartSVG:
215
218
  self.t_houses_sign_graph.append(h["sign_num"])
216
219
 
217
220
  # screen size
218
- if self.chart_type == "Natal":
219
- self.screen_width = 772.2
221
+
222
+ self.height = self._DEFAULT_HEIGHT
223
+ if self.chart_type == "Synastry" or self.chart_type == "Transit":
224
+ self.width = self._DEFAULT_FULL_WIDTH
220
225
  else:
221
- self.screen_width = 1200
222
- self.screen_height = 772.2
226
+ self.width = self._DEFAULT_NATAL_WIDTH
223
227
 
224
228
  # default location
225
229
  self.location = self.user.city
@@ -250,8 +254,7 @@ class KerykeionChartSVG:
250
254
  {"name": "pisces", "element": "water"},
251
255
  )
252
256
 
253
- # Immediately generate template.
254
- self.template = self.makeTemplate()
257
+ self.template = None
255
258
 
256
259
  def set_output_directory(self, dir_path: Path) -> None:
257
260
  """
@@ -1152,13 +1155,6 @@ class KerykeionChartSVG:
1152
1155
  # Calculate the elements points
1153
1156
  self._calculate_elements_points_from_planets()
1154
1157
 
1155
- # width and height from screen
1156
- ratio = float(self.screen_width) / float(self.screen_height)
1157
- if ratio < 1.3: # 1280x1024
1158
- wm_off = 130
1159
- else: # 1024x768, 800x600, 1280x800, 1680x1050
1160
- wm_off = 100
1161
-
1162
1158
  # Viewbox and sizing
1163
1159
  svgHeight = "100%"
1164
1160
  svgWidth = "100%"
@@ -1190,10 +1186,8 @@ class KerykeionChartSVG:
1190
1186
  td["degreeRing"] = draw_transit_ring_degree_steps(r, self.user.seventh_house.abs_pos)
1191
1187
 
1192
1188
  # circles
1193
- td["c1"] = f'cx="{r}" cy="{r}" r="{r - 36}"'
1194
- td["c1style"] = f'fill: none; stroke: {self.chart_colors_settings["zodiac_transit_ring_2"]}; stroke-width: 1px; stroke-opacity:.4;'
1195
- td["c2"] = 'cx="' + str(r) + '" cy="' + str(r) + '" r="' + str(r - 72) + '"'
1196
- td["c2style"] = f"fill: {self.chart_colors_settings['paper_1']}; fill-opacity:.4; stroke: {self.chart_colors_settings['zodiac_transit_ring_1']}; stroke-opacity:.4; stroke-width: 1px"
1189
+ td["first_circle"] = draw_first_circle(r, self.chart_colors_settings["zodiac_transit_ring_2"], self.chart_type)
1190
+ td["second_circle"] = draw_second_circle(r, self.chart_colors_settings['zodiac_transit_ring_1'], self.chart_colors_settings['paper_1'], self.chart_type)
1197
1191
 
1198
1192
  td["c3"] = 'cx="' + str(r) + '" cy="' + str(r) + '" r="' + str(r - 160) + '"'
1199
1193
  td["c3style"] = f"fill: {self.chart_colors_settings['paper_1']}; fill-opacity:.8; stroke: {self.chart_colors_settings['zodiac_transit_ring_0']}; stroke-width: 1px"
@@ -1201,23 +1195,23 @@ class KerykeionChartSVG:
1201
1195
  td["makeAspects"] = self._makeAspectsTransit(r, (r - 160))
1202
1196
  td["makeAspectGrid"] = self._makeAspectTransitGrid(r)
1203
1197
  td["makePatterns"] = ""
1204
- td["chart_width"] = self.full_width
1205
1198
  else:
1206
1199
  td["transitRing"] = ""
1207
1200
  td["degreeRing"] = draw_degree_ring(r, self.c1, self.user.seventh_house.abs_pos, self.chart_colors_settings["paper_0"])
1208
1201
 
1209
- # circles
1210
- td["c1"] = f'cx="{r}" cy="{r}" r="{r - self.c1}"'
1211
- td["c1style"] = f'fill: none; stroke: {self.chart_colors_settings["zodiac_radix_ring_2"]}; stroke-width: 1px; '
1212
- td["c2"] = f'cx="{r}" cy="{r}" r="{r - self.c2}"'
1213
- td["c2style"] = f'fill: {self.chart_colors_settings["paper_1"]}; fill-opacity:.2; stroke: {self.chart_colors_settings["zodiac_radix_ring_1"]}; stroke-opacity:.4; stroke-width: 1px'
1202
+ td['first_circle'] = draw_first_circle(r, self.chart_colors_settings["zodiac_radix_ring_2"], self.chart_type, self.c1)
1203
+
1204
+ td["second_circle"] = draw_second_circle(r, self.chart_colors_settings["zodiac_radix_ring_1"], self.chart_colors_settings["paper_1"], self.chart_type, self.c2)
1205
+
1214
1206
  td["c3"] = f'cx="{r}" cy="{r}" r="{r - self.c3}"'
1215
1207
  td["c3style"] = f'fill: {self.chart_colors_settings["paper_1"]}; fill-opacity:.8; stroke: {self.chart_colors_settings["zodiac_radix_ring_0"]}; stroke-width: 1px'
1208
+
1216
1209
  td["makeAspects"] = self._makeAspects(r, (r - self.c3))
1217
1210
  td["makeAspectGrid"] = self._makeAspectGrid(r)
1218
1211
  td["makePatterns"] = self._makePatterns()
1219
- td["chart_width"] = self.natal_width
1220
-
1212
+
1213
+ td["chart_height"] = self.height
1214
+ td["chart_width"] = self.width
1221
1215
  td["circleX"] = str(0)
1222
1216
  td["circleY"] = str(0)
1223
1217
  td["svgWidth"] = str(svgWidth)
@@ -1379,7 +1373,7 @@ class KerykeionChartSVG:
1379
1373
 
1380
1374
  return td
1381
1375
 
1382
- def makeTemplate(self):
1376
+ def makeTemplate(self, minify: bool = False) -> str:
1383
1377
  """Creates the template for the SVG file"""
1384
1378
  td = self._createTemplateDictionary()
1385
1379
 
@@ -1392,13 +1386,20 @@ class KerykeionChartSVG:
1392
1386
  logging.debug(f"Template dictionary keys: {td.keys()}")
1393
1387
 
1394
1388
  self._createTemplateDictionary()
1395
- return template.replace('"', "'")
1396
1389
 
1397
- def makeSVG(self) -> None:
1390
+ if minify:
1391
+ template = scourString(template).replace('"', "'").replace("\n", "").replace("\t","").replace(" ", "").replace(" ", "")
1392
+
1393
+ else:
1394
+ template = template.replace('"', "'")
1395
+
1396
+ return template
1397
+
1398
+ def makeSVG(self, minify: bool = False):
1398
1399
  """Prints out the SVG file in the specifide folder"""
1399
1400
 
1400
1401
  if not (self.template):
1401
- self.template = self.makeTemplate()
1402
+ self.template = self.makeTemplate(minify)
1402
1403
 
1403
1404
  self.chartname = self.output_directory / f"{self.user.name}{self.chart_type}Chart.svg"
1404
1405
 
@@ -1425,8 +1426,9 @@ if __name__ == "__main__":
1425
1426
 
1426
1427
  # Synastry Chart
1427
1428
  synastry_chart = KerykeionChartSVG(first, "Synastry", second)
1428
- synastry_chart.makeSVG()
1429
+ synastry_chart.makeSVG(minify=True)
1429
1430
 
1430
1431
  # Transits Chart
1431
1432
  transits_chart = KerykeionChartSVG(first, "Transit", second)
1432
- transits_chart.makeSVG()
1433
+ transits_chart.makeSVG(minify=True)
1434
+
@@ -12,7 +12,7 @@
12
12
  <g transform="translate($cfgTranslate)">
13
13
  <g transform="rotate($cfgRotate)">
14
14
  <g transform="scale($cfgZoom)">
15
- <rect x="0" y="0" width="$chart_width" height="546.0" style="fill: $paper_color_1" />
15
+ <rect class="background-rectangle" x="0" y="0" width="$chart_width" height="$chart_height" style="fill: $paper_color_1" />
16
16
  <text x="20" y="30" style="fill: $paper_color_0; font-size: 24px">$stringTitle</text>
17
17
  <text x="20" y="50" style="fill: $paper_color_0; font-size: 11px">$stringName</text>
18
18
  <text x="20" y="62" style="fill: $paper_color_0; font-size: 11px">$stringLocation</text>
@@ -471,10 +471,10 @@
471
471
  $makeZodiac
472
472
 
473
473
  <!-- First Circle -->
474
- <circle $c1 style="$c1style" />
474
+ $first_circle
475
475
 
476
476
  <!-- Second Circle -->
477
- <circle $c2 style="$c2style" />
477
+ $second_circle
478
478
 
479
479
  <!-- Third Circle -->
480
480
  <circle $c3 style="$c3style" />
@@ -82,7 +82,9 @@ class FetchGeonames:
82
82
  "contry": country_code,
83
83
  "username": self.username,
84
84
  "maxRows": 1,
85
- "style": "FULL",
85
+ "style": "SHORT",
86
+ "featureClass": "A",
87
+ "featureClass": "P",
86
88
  }
87
89
 
88
90
  prepared_request = Request("GET", self.base_url, params=params).prepare()
@@ -91,6 +93,7 @@ class FetchGeonames:
91
93
  try:
92
94
  response = self.session.send(prepared_request)
93
95
  response_json = response.json()
96
+ logging.debug(f"Response from GeoNames: {response_json}")
94
97
 
95
98
  except Exception as e:
96
99
  logging.error(f"Error in fetching {self.base_url}: {e}")
@@ -133,5 +136,5 @@ if __name__ == "__main__":
133
136
  from kerykeion.utilities import setup_logging
134
137
  setup_logging(level="debug")
135
138
 
136
- geonames = FetchGeonames("Roma", "IT")
139
+ geonames = FetchGeonames("Montichiari", "IT")
137
140
  print(geonames.get_serialized_data())
@@ -4,15 +4,14 @@ from typing import TypedDict
4
4
  class ChartTemplateDictionary(TypedDict):
5
5
  transitRing: str
6
6
  degreeRing: str
7
- c1: str
8
- c1style: str
9
- c2: str
10
- c2style: str
7
+ first_circle: str
8
+ second_circle: str
11
9
  c3: str
12
10
  c3style: str
13
11
  makeAspects: str
14
12
  makeAspectGrid: str
15
13
  makePatterns: str
14
+ chart_height: float
16
15
  chart_width: float
17
16
  circleX: str
18
17
  circleY: str
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "kerykeion"
3
- version = "4.7.0"
3
+ version = "4.8.1"
4
4
  authors = ["Giacomo Battaglia <battaglia.giacomo@yahoo.it>"]
5
5
  description = "A python library for astrology."
6
6
  license = "AGPL-3.0"
@@ -48,6 +48,7 @@ requests = "^2.28.1"
48
48
  requests-cache = "^0.9.7"
49
49
  pydantic = "^2.5"
50
50
  terminaltables = "^3.1.10"
51
+ scour = "^0.38.2"
51
52
 
52
53
  [tool.poetry.scripts]
53
54
  create-docs = "scripts.docs:main"
File without changes
File without changes
File without changes
File without changes