# kerykeion.report

View Source

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

class Report: View Source

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

Create a report for a Kerykeion instance.

Report( instance: Union[kerykeion.astrological_subject.AstrologicalSubject, kerykeion.kr_types.kr_models.AstrologicalSubjectModel]) View Source

    18    def __init__(self, instance: Union[AstrologicalSubject, AstrologicalSubjectModel]):
    19        self.instance = instance
    20
    21        self.get_report_title()
    22        self.get_data_table()
    23        self.get_planets_table()
    24        self.get_houses_table()

report_title: str
data_table: str
planets_table: str
houses_table: str
instance
def get_report_title(self) -> None: View Source

    26    def get_report_title(self) -> None:
    27        self.report_title = f"\n+- Kerykeion report for {self.instance.name} -+"

def get_data_table(self) -> None: View Source

    29    def get_data_table(self) -> None:
    30        """
    31        Creates the data table of the report.
    32        """
    33
    34        main_data = [["Date", "Time", "Location", "Longitude", "Latitude"]] + [
    35            [
    36                f"{self.instance.day}/{self.instance.month}/{self.instance.year}",
    37                f"{self.instance.hour}:{self.instance.minute}",
    38                f"{self.instance.city}, {self.instance.nation}",
    39                self.instance.lng,
    40                self.instance.lat,
    41            ]
    42        ]
    43        self.data_table = AsciiTable(main_data).table

Creates the data table of the report.

def get_planets_table(self) -> None: View Source

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

Creates the planets table.

def get_houses_table(self) -> None: View Source

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

Creates the houses table.

def get_full_report(self) -> str: View Source

    74    def get_full_report(self) -> str:
    75        """
    76        Returns the full report.
    77        """
    78
    79        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: View Source

    81    def print_report(self) -> None:
    82        """
    83        Print the report.
    84        """
    85
    86        print(self.get_full_report())

Print the report.