# Path: l5r/util/log.py
# def log_setup(base_path, base_name):
# 
# Path: l5r/util/settings.py
# class L5RCMSettings(object):
#     """A QSettings wrapper for easy access to application settings"""
# 
#     def __init__(self):
#         self._qsettings = QSettings()
# 
#         # Application settings
#         self._app = L5RCMSettings_App(self._qsettings)
#         # UI settings
#         self._ui = L5RCMSettings_UI(self._qsettings)
#         # PC export PDF generation settings
#         self._pc_export = L5RCMSettings_PcExport(self._qsettings)
#         # NPC export PDF generation settings
#         self._npc_export = L5RCMSettings_NpcExport(self._qsettings)
# 
#     @property
#     def app(self):
#         return self._app
# 
#     @property
#     def ui(self):
#         return self._ui
# 
#     @property
#     def pc_export(self):
#         return self._pc_export
# 
#     @property
#     def npc_export(self):
#         return self._npc_export
# 
#     def sync(self):
#         self._qsettings.sync()
# 
#     def load_defaults(self):
#         self._app.load_defaults()
#         self._ui.load_defaults()
#         self._pc_export.load_defaults()
#         self._npc_export.load_defaults()


from PyQt5 import QtCore, QtGui
from l5r.util import log
from l5r.util.settings import L5RCMSettings
import l5r.api as api
import l5r.api.character.merits
import l5r.api.character.flaws
import l5r.api.data.merits
import l5r.api.data.flaws
        else:
            log.model.error(u"perk not found: %s", perk_adv.perk)

        return itm

    def add_item(self, model, item_id):
        row = self.rowCount()
        self.beginInsertRows(QtCore.QModelIndex(), row, row)
        self.items.append(self.build_item_model(model, item_id))
        self.endInsertRows()

    def clean(self):
        self.beginResetModel()
        self.items = []
        self.endResetModel()

    def update_from_model(self, model):
        self.clean()
        if self.type == 'merit':
            for perk in api.character.merits.get_all():
                self.add_item(model, perk)
        else:
            for perk in api.character.flaws.get_all():
                self.add_item(model, perk)

    def data(self, index, role):
        if not index.isValid() or index.row() >= len(self.items):
            return None
        item = self.items[index.row()]
        if role == QtCore.Qt.DisplayRole:

# Path: l5r/util/log.py
# def log_setup(base_path, base_name):
# 
# Path: l5r/util/settings.py
# class L5RCMSettings(object):
#     """A QSettings wrapper for easy access to application settings"""
# 
#     def __init__(self):
#         self._qsettings = QSettings()
# 
#         # Application settings
#         self._app = L5RCMSettings_App(self._qsettings)
#         # UI settings
#         self._ui = L5RCMSettings_UI(self._qsettings)
#         # PC export PDF generation settings
#         self._pc_export = L5RCMSettings_PcExport(self._qsettings)
#         # NPC export PDF generation settings
#         self._npc_export = L5RCMSettings_NpcExport(self._qsettings)
# 
#     @property
#     def app(self):
#         return self._app
# 
#     @property
#     def ui(self):
#         return self._ui
# 
#     @property
#     def pc_export(self):
#         return self._pc_export
# 
#     @property
#     def npc_export(self):
#         return self._npc_export
# 
#     def sync(self):
#         self._qsettings.sync()
# 
#     def load_defaults(self):
#         self._app.load_defaults()
#         self._ui.load_defaults()
#         self._pc_export.load_defaults()
#         self._npc_export.load_defaults()


# Path: l5r/models/perkviewmodel.py
from PyQt5 import QtCore, QtGui
from l5r.util import log
from l5r.util.settings import L5RCMSettings
import l5r.api as api
import l5r.api.character.merits
import l5r.api.character.flaws
import l5r.api.data.merits
import l5r.api.data.flaws

        else:
            log.model.error(u"perk not found: %s", perk_adv.perk)

        return itm

    def add_item(self, model, item_id):
        row = self.rowCount()
        self.beginInsertRows(QtCore.QModelIndex(), row, row)
        self.items.append(self.build_item_model(model, item_id))
        self.endInsertRows()

    def clean(self):
        self.beginResetModel()
        self.items = []
        self.endResetModel()

    def update_from_model(self, model):
        self.clean()
        if self.type == 'merit':
            for perk in api.character.merits.get_all():
                self.add_item(model, perk)
        else:
            for perk in api.character.flaws.get_all():
                self.add_item(model, perk)

    def data(self, index, role):
        if not index.isValid() or index.row() >= len(self.items):
            return None
        item = self.items[index.row()]
        if role == QtCore.Qt.DisplayRole:

            if index.column() == 0: