from db import Base
from sqlalchemy import Column, Unicode, Boolean

metadata = Base.metadata

class Plugin(Base):
    __tablename__ = 'plugin'

    name = Column(Unicode(256), primary_key=True)
    human_name = Column(Unicode(256))
    version = Column(Unicode(256))
    enabled = Column(Boolean)

    def __init__(self, plugin):
        self.name = plugin.name
        self.human_name = plugin.human_name
        self.version = plugin.version.__str__()
        self.enabled = plugin.enabled

    def update(self, plugin):
        self.__init__(plugin)
