# Path: cliche/orm.py
# def make_repr(self):
# def get_alembic_config(engine):
# def initialize_database(engine):
# def get_database_revision(engine):
#     def get_revision(rev, context):
# def upgrade_database(engine, revision='head'):
#     def upgrade(rev, context):
#         def update_current_rev(old, new):
# def downgrade_database(engine, revision):
# def import_all_modules(dry_run=False):  # FIXME
# 
# Path: cliche/work.py
# class Work(Nameable):
#     """Creative work(s) that could be a single work like a film, or
#     a series of works such as a combic book series and a television series.
#     """
# 
#     #: (:class:`int`) The primary key integer.
#     id = Column(Integer, ForeignKey(Nameable.id), primary_key=True)
# 
#     #: (:class:`str`) Work media type.
#     media_type = Column(String, nullable=False)
# 
#     #: (:class:`datetime.date`) The publication date.
#     published_at = Column(Date)
# 
#     #: (:class:`collections.abc.MutableSet`) The set of
#     #: :class:`WorkGenre`\ s that the work has.
#     work_genres = relationship('WorkGenre',
#                                cascade='delete, merge, save-update',
#                                collection_class=set)
# 
#     #: (:class:`collections.abc.MutableSet`) The set of
#     #: :class:`Genre`\ s that the work falls into.
#     genres = relationship(Genre,
#                           secondary='work_genres',
#                           collection_class=set)
# 
#     #: (:class:`collections.abc.MutableSet`) The set of
#     #: :class:`Credit`\ s that the work has.
#     credits = relationship(Credit,
#                            cascade='delete, merge, save-update',
#                            collection_class=set)
# 
#     #: (:class:`collections.abc.MutableSet`) The set of
#     #: :class:`WorkFranchise`\ s that the work has.
#     work_franchises = relationship('WorkFranchise',
#                                    cascade='delete, merge, save-update',
#                                    collection_class=set)
# 
#     #: (:class:`collections.abc.MutableSet`) The set of
#     #: :class:`Franchise`\ s that the work belongs to.
#     franchises = relationship(Franchise,
#                               secondary='work_franchises',
#                               collection_class=set)
# 
#     #: (:class:`collections.abc.MutableSet`) The set of
#     #: :class:`Character`\ s that appeared in the work.
#     characters = relationship(Character,
#                               secondary='work_characters',
#                               collection_class=set)
# 
#     #: (:class:`collections.abc.MutableSet`) The set of
#     #: :class:`WorkTrope`.
#     work_tropes = relationship(lambda: WorkTrope,
#                                cascade='delete, merge, save-update',
#                                collection_class=set)
# 
#     #: (:class:`collections.abc.MutableSet`) The set of
#     #: :class:`Trope`.
#     tropes = relationship(Trope, secondary='work_tropes',
#                           collection_class=set)
# 
#     #: (:class:`datetime.datetime`) The date and time on which
#     #: the record was created.
#     created_at = Column(DateTime(timezone=True),
#                         nullable=False,
#                         default=now(),
#                         index=True)
# 
#     __tablename__ = 'works'
#     __repr_columns__ = [id]
#     __mapper_args__ = {
#         'polymorphic_identity': 'works',
#     }


from urllib.parse import unquote_plus
from sqlalchemy import (Boolean, Column, DateTime, Float, ForeignKey, Integer,
                        String)
from sqlalchemy.orm import relationship
from ...orm import Base
from ...work import Work as ClicheWork
    PROPERTIES = Work.PROPERTIES | {
        'dbpedia-owl:illustrator',
        'dbpedia-owl:isbn',
        'dbpedia-owl:numberOfPages'
    }

    illustrator = Column(String)
    isbn = Column(String)
    number_of_pages = Column(Integer)

    __mapper_args__ = {
        'polymorphic_identity': 'book'
    }

    @classmethod
    def initialize(cls, item):
        temp = super().initialize(item)
        temp.illustrator = item.get('illustrator', None)
        temp.isbn = item.get('isbn', None)
        temp.number_of_pages = item.get('numberOfPages', None)
        return temp

    def get_identities():
        return 'dbpedia-owl:Book'


class ClicheWikipediaEdge(Base):
    """Correspondence between Works of Cliche and Wikipedia"""

    cliche_id = Column(Integer, ForeignKey('works.id'), primary_key=True)

# Path: cliche/orm.py
# def make_repr(self):
# def get_alembic_config(engine):
# def initialize_database(engine):
# def get_database_revision(engine):
#     def get_revision(rev, context):
# def upgrade_database(engine, revision='head'):
#     def upgrade(rev, context):
#         def update_current_rev(old, new):
# def downgrade_database(engine, revision):
# def import_all_modules(dry_run=False):  # FIXME
# 
# Path: cliche/work.py
# class Work(Nameable):
#     """Creative work(s) that could be a single work like a film, or
#     a series of works such as a combic book series and a television series.
#     """
# 
#     #: (:class:`int`) The primary key integer.
#     id = Column(Integer, ForeignKey(Nameable.id), primary_key=True)
# 
#     #: (:class:`str`) Work media type.
#     media_type = Column(String, nullable=False)
# 
#     #: (:class:`datetime.date`) The publication date.
#     published_at = Column(Date)
# 
#     #: (:class:`collections.abc.MutableSet`) The set of
#     #: :class:`WorkGenre`\ s that the work has.
#     work_genres = relationship('WorkGenre',
#                                cascade='delete, merge, save-update',
#                                collection_class=set)
# 
#     #: (:class:`collections.abc.MutableSet`) The set of
#     #: :class:`Genre`\ s that the work falls into.
#     genres = relationship(Genre,
#                           secondary='work_genres',
#                           collection_class=set)
# 
#     #: (:class:`collections.abc.MutableSet`) The set of
#     #: :class:`Credit`\ s that the work has.
#     credits = relationship(Credit,
#                            cascade='delete, merge, save-update',
#                            collection_class=set)
# 
#     #: (:class:`collections.abc.MutableSet`) The set of
#     #: :class:`WorkFranchise`\ s that the work has.
#     work_franchises = relationship('WorkFranchise',
#                                    cascade='delete, merge, save-update',
#                                    collection_class=set)
# 
#     #: (:class:`collections.abc.MutableSet`) The set of
#     #: :class:`Franchise`\ s that the work belongs to.
#     franchises = relationship(Franchise,
#                               secondary='work_franchises',
#                               collection_class=set)
# 
#     #: (:class:`collections.abc.MutableSet`) The set of
#     #: :class:`Character`\ s that appeared in the work.
#     characters = relationship(Character,
#                               secondary='work_characters',
#                               collection_class=set)
# 
#     #: (:class:`collections.abc.MutableSet`) The set of
#     #: :class:`WorkTrope`.
#     work_tropes = relationship(lambda: WorkTrope,
#                                cascade='delete, merge, save-update',
#                                collection_class=set)
# 
#     #: (:class:`collections.abc.MutableSet`) The set of
#     #: :class:`Trope`.
#     tropes = relationship(Trope, secondary='work_tropes',
#                           collection_class=set)
# 
#     #: (:class:`datetime.datetime`) The date and time on which
#     #: the record was created.
#     created_at = Column(DateTime(timezone=True),
#                         nullable=False,
#                         default=now(),
#                         index=True)
# 
#     __tablename__ = 'works'
#     __repr_columns__ = [id]
#     __mapper_args__ = {
#         'polymorphic_identity': 'works',
#     }


# Path: cliche/services/wikipedia/work.py
from urllib.parse import unquote_plus
from sqlalchemy import (Boolean, Column, DateTime, Float, ForeignKey, Integer,
                        String)
from sqlalchemy.orm import relationship
from ...orm import Base
from ...work import Work as ClicheWork

    PROPERTIES = Work.PROPERTIES | {
        'dbpedia-owl:illustrator',
        'dbpedia-owl:isbn',
        'dbpedia-owl:numberOfPages'
    }

    illustrator = Column(String)
    isbn = Column(String)
    number_of_pages = Column(Integer)

    __mapper_args__ = {
        'polymorphic_identity': 'book'
    }

    @classmethod
    def initialize(cls, item):
        temp = super().initialize(item)
        temp.illustrator = item.get('illustrator', None)
        temp.isbn = item.get('isbn', None)
        temp.number_of_pages = item.get('numberOfPages', None)
        return temp

    def get_identities():
        return 'dbpedia-owl:Book'


class ClicheWikipediaEdge(Base):
    """Correspondence between Works of Cliche and Wikipedia"""

    cliche_id = Column(Integer, ForeignKey('works.id'), primary_key=True)

    cliche_work = relationship(ClicheWork)