kerykeion.report

 1from kerykeion import AstrologicalSubject
 2from terminaltables import AsciiTable
 3
 4class Report:
 5    """
 6    Create a report for a Kerykeion instance.
 7    """
 8
 9    report_title: str
10    data_table: str
11    planets_table: str
12    houses_table: str
13
14    def __init__(self, instance: AstrologicalSubject):
15        self.instance = instance
16
17        self.get_report_title()
18        self.get_data_table()
19        self.get_planets_table()
20        self.get_houses_table()
21
22    def get_report_title(self) -> None:
23        self.report_title = f"\n+- Kerykeion report for {self.instance.name} -+"
24
25    def get_data_table(self) -> None:
26        """
27        Creates the data table of the report.
28        """
29
30        main_data = [["Date", "Time", "Location", "Longitude", "Latitude"]] + [
31            [
32                f"{self.instance.day}/{self.instance.month}/{self.instance.year}",
33                f"{self.instance.hour}:{self.instance.minute}",
34                f"{self.instance.city}, {self.instance.nation}",
35                self.instance.lng,
36                self.instance.lat,
37            ]
38        ]
39        self.data_table = AsciiTable(main_data).table
40
41    def get_planets_table(self) -> None:
42        """
43        Creates the planets table.
44        """
45
46        planets_data = [["Planet", "Sign", "Pos.", "Ret.", "House"]] + [
47            [
48                planet.name,
49                planet.sign,
50                round(float(planet.position), 2),
51                ("R" if planet.retrograde else "-"),
52                planet.house,
53            ]
54            for planet in self.instance.planets_list
55        ]
56
57        self.planets_table = AsciiTable(planets_data).table
58
59    def get_houses_table(self) -> None:
60        """
61        Creates the houses table.
62        """
63
64        houses_data = [["House", "Sign", "Position"]] + [
65            [house.name, house.sign, round(float(house.position), 2)] for house in self.instance.houses_list
66        ]
67
68        self.houses_table = AsciiTable(houses_data).table
69
70    def get_full_report(self) -> str:
71        """
72        Returns the full report.
73        """
74
75        return f"{self.report_title}\n{self.data_table}\n{self.planets_table}\n{self.houses_table}"
76
77    def print_report(self) -> None:
78        """
79        Print the report.
80        """
81
82        print(self.get_full_report())
83
84
85if __name__ == "__main__":
86    from kerykeion.utilities import setup_logging
87    setup_logging(level="debug")
88
89    john = AstrologicalSubject("John", 1975, 10, 10, 21, 15, "Roma", "IT")
90    report = Report(john)
91    report.print_report()
class Report:
 5class Report:
 6    """
 7    Create a report for a Kerykeion instance.
 8    """
 9
10    report_title: str
11    data_table: str
12    planets_table: str
13    houses_table: str
14
15    def __init__(self, instance: AstrologicalSubject):
16        self.instance = instance
17
18        self.get_report_title()
19        self.get_data_table()
20        self.get_planets_table()
21        self.get_houses_table()
22
23    def get_report_title(self) -> None:
24        self.report_title = f"\n+- Kerykeion report for {self.instance.name} -+"
25
26    def get_data_table(self) -> None:
27        """
28        Creates the data table of the report.
29        """
30
31        main_data = [["Date", "Time", "Location", "Longitude", "Latitude"]] + [
32            [
33                f"{self.instance.day}/{self.instance.month}/{self.instance.year}",
34                f"{self.instance.hour}:{self.instance.minute}",
35                f"{self.instance.city}, {self.instance.nation}",
36                self.instance.lng,
37                self.instance.lat,
38            ]
39        ]
40        self.data_table = AsciiTable(main_data).table
41
42    def get_planets_table(self) -> None:
43        """
44        Creates the planets table.
45        """
46
47        planets_data = [["Planet", "Sign", "Pos.", "Ret.", "House"]] + [
48            [
49                planet.name,
50                planet.sign,
51                round(float(planet.position), 2),
52                ("R" if planet.retrograde else "-"),
53                planet.house,
54            ]
55            for planet in self.instance.planets_list
56        ]
57
58        self.planets_table = AsciiTable(planets_data).table
59
60    def get_houses_table(self) -> None:
61        """
62        Creates the houses table.
63        """
64
65        houses_data = [["House", "Sign", "Position"]] + [
66            [house.name, house.sign, round(float(house.position), 2)] for house in self.instance.houses_list
67        ]
68
69        self.houses_table = AsciiTable(houses_data).table
70
71    def get_full_report(self) -> str:
72        """
73        Returns the full report.
74        """
75
76        return f"{self.report_title}\n{self.data_table}\n{self.planets_table}\n{self.houses_table}"
77
78    def print_report(self) -> None:
79        """
80        Print the report.
81        """
82
83        print(self.get_full_report())

Create a report for a Kerykeion instance.

15    def __init__(self, instance: AstrologicalSubject):
16        self.instance = instance
17
18        self.get_report_title()
19        self.get_data_table()
20        self.get_planets_table()
21        self.get_houses_table()
report_title: str
data_table: str
planets_table: str
houses_table: str
instance
def get_report_title(self) -> None:
23    def get_report_title(self) -> None:
24        self.report_title = f"\n+- Kerykeion report for {self.instance.name} -+"
def get_data_table(self) -> None:
26    def get_data_table(self) -> None:
27        """
28        Creates the data table of the report.
29        """
30
31        main_data = [["Date", "Time", "Location", "Longitude", "Latitude"]] + [
32            [
33                f"{self.instance.day}/{self.instance.month}/{self.instance.year}",
34                f"{self.instance.hour}:{self.instance.minute}",
35                f"{self.instance.city}, {self.instance.nation}",
36                self.instance.lng,
37                self.instance.lat,
38            ]
39        ]
40        self.data_table = AsciiTable(main_data).table

Creates the data table of the report.

def get_planets_table(self) -> None:
42    def get_planets_table(self) -> None:
43        """
44        Creates the planets table.
45        """
46
47        planets_data = [["Planet", "Sign", "Pos.", "Ret.", "House"]] + [
48            [
49                planet.name,
50                planet.sign,
51                round(float(planet.position), 2),
52                ("R" if planet.retrograde else "-"),
53                planet.house,
54            ]
55            for planet in self.instance.planets_list
56        ]
57
58        self.planets_table = AsciiTable(planets_data).table

Creates the planets table.

def get_houses_table(self) -> None:
60    def get_houses_table(self) -> None:
61        """
62        Creates the houses table.
63        """
64
65        houses_data = [["House", "Sign", "Position"]] + [
66            [house.name, house.sign, round(float(house.position), 2)] for house in self.instance.houses_list
67        ]
68
69        self.houses_table = AsciiTable(houses_data).table

Creates the houses table.

def get_full_report(self) -> str:
71    def get_full_report(self) -> str:
72        """
73        Returns the full report.
74        """
75
76        return f"{self.report_title}\n{self.data_table}\n{self.planets_table}\n{self.houses_table}"

Returns the full report.

def print_report(self) -> None:
78    def print_report(self) -> None:
79        """
80        Print the report.
81        """
82
83        print(self.get_full_report())

Print the report.