HistoricalEvent documentation#
- class historical_timelines.HistoricalEvent(title: str, description: str, start: HistoricalDate, end: HistoricalDate = None, label: str = None)#
get_random_event
- static event_from_dict(event_dict: object) HistoricalEvent#
Takes in a dictionary entry and turns it into a HistoricalEvent
- Args:
event_dict (object): A dictionary representing a HistoricalEvent
- Returns:
HistoricalEvent: The converted event
- get_adjusted_year()#
Get the year adjusted for the AD/BC timeline. Returns an int if the event is an event, and a tuple if the event is a period.
- Returns:
int | tuple[int, int]: The year(s), adjusted for AD/BC.
- get_label_or_default(default: str = 'default') str#
Get get the label if it exists, otherwise return a default string
- Args:
default (str, optional): The string to use if the label isn’t found. Defaults to ‘default’.
- Returns:
str: The label or default string
- static get_random_event() HistoricalEvent#
Generate a random event
- Returns:
HistoricalEvent: A random event
- static get_random_string(N: int = 7) str#
Generate a random string
- Args:
N (int, optional): The length of the string. Defaults to 7.
- Returns:
str: The random string
- get_title_with_newlines(max_line_width: int = 10) str#
Get the event’s title with newlines placed
Newlines are inserted in the first word break after the max_line_width variable. Good for making sure timeline labels aren’t cramped.
- Args:
max_line_width (int, optional): The maximum length a line is allowed to be before a newline is inserted after the next word. Defaults to 10.
- Returns:
str: The event’s title, with newlines inserted.
- is_event() bool#
If an event is an event
Checks an events event type to see if it is an event, as in a single point in time.
- is_period() bool#
If an event is a period
Checks an events event type to see if it is a period, as in a time period between two dates.