# Path: l5r/util/log.py
# def log_setup(base_path, base_name):


from pydoc import pager
from PyQt5 import QtCore, QtGui, QtWidgets
from asq.initiators import query
from asq.selectors import a_
from l5r.util import log
import l5r.api as api
import l5r.api.data
import l5r.api.data.families
import l5r.api.data.clans
    import sys

    def on_family_changed(self, index_or_text):
        self.current_family_id = self.cb_family.itemData(self.cb_family.currentIndex())
        self.update_bonus_trait()
        self.update_book()

    def update_book(self):
        try:
            family_data = api.data.families.get(self.current_family_id)
            source_book = family_data.pack
            page_number = family_data.page

            if not source_book:
                self.lb_book.setText("")
            elif not page_number:                
                self.lb_book.setText(em(source_book.display_name))
            else:
                self.lb_book.setText(em(self.tr(f"{source_book.display_name}, page {page_number}")))
        except:
            log.ui.error(f'cannot load source book for family: {self.current_family_id}', exc_info=1)

    def update_bonus_trait(self):
        try:
            bonus_trait = api.data.families.get(self.current_family_id).trait

            if not bonus_trait:
                self.lb_trait.setText("")
            else:
                self.lb_trait.setText(green("+1 {}").format(api.data.get_trait_or_ring(bonus_trait)))
        except:

# Path: l5r/util/log.py
# def log_setup(base_path, base_name):


# Path: l5r/widgets/familychooser.py
from pydoc import pager
from PyQt5 import QtCore, QtGui, QtWidgets
from asq.initiators import query
from asq.selectors import a_
from l5r.util import log
import l5r.api as api
import l5r.api.data
import l5r.api.data.families
import l5r.api.data.clans
    import sys


    def on_family_changed(self, index_or_text):
        self.current_family_id = self.cb_family.itemData(self.cb_family.currentIndex())
        self.update_bonus_trait()
        self.update_book()

    def update_book(self):
        try:
            family_data = api.data.families.get(self.current_family_id)
            source_book = family_data.pack
            page_number = family_data.page

            if not source_book:
                self.lb_book.setText("")
            elif not page_number:                
                self.lb_book.setText(em(source_book.display_name))
            else:
                self.lb_book.setText(em(self.tr(f"{source_book.display_name}, page {page_number}")))
        except:
            log.ui.error(f'cannot load source book for family: {self.current_family_id}', exc_info=1)

    def update_bonus_trait(self):
        try:
            bonus_trait = api.data.families.get(self.current_family_id).trait

            if not bonus_trait:
                self.lb_trait.setText("")
            else:
                self.lb_trait.setText(green("+1 {}").format(api.data.get_trait_or_ring(bonus_trait)))
        except:

            log.ui.error(f'cannot load bonus trait for family: {self.current_family_id}', exc_info=1)