Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from clld.db.meta import Base, PolymorphicBaseMixin
from clld.db.versioned import Versioned
from clld import interfaces
from . import (
IdNameDescriptionMixin, DataMixin, HasDataMixin, FilesMixin, HasFilesMixin, Language)
__all__ = ('Unit',)
class Unit_data(Base, Versioned, DataMixin):
pass
class Unit_files(Base, Versioned, FilesMixin):
pass
@implementer(interfaces.IUnit)
class Unit(Base,
PolymorphicBaseMixin,
Versioned,
IdNameDescriptionMixin,
HasDataMixin,
HasFilesMixin):
"""A linguistic unit of a language."""
__table_args__ = (UniqueConstraint('language_pk', 'id'),)
language_pk = Column(Integer, ForeignKey('language.pk'), nullable=False)
language = relationship(Language, innerjoin=True)
from zope.interface import implementer
from nameparser import HumanName
from clld.db.meta import Base, PolymorphicBaseMixin
from clld.db.versioned import Versioned
from clld import interfaces
from .import (
IdNameDescriptionMixin,
DataMixin, FilesMixin, HasDataMixin, HasFilesMixin)
__all__ = ('Contributor',)
class Contributor_data(Base, Versioned, DataMixin):
pass
class Contributor_files(Base, Versioned, FilesMixin):
pass
@implementer(interfaces.IContributor)
class Contributor(Base,
PolymorphicBaseMixin,
Versioned,
IdNameDescriptionMixin,
HasDataMixin,
HasFilesMixin):
"""Creator of a contribution."""
from sqlalchemy.ext.declarative import declared_attr
from zope.interface import implementer
from clld.db.meta import Base, PolymorphicBaseMixin
from clld.db.versioned import Versioned
from clld import interfaces
from . import (
IdNameDescriptionMixin,
DataMixin, HasDataMixin, FilesMixin, HasFilesMixin, HasSourceNotNullMixin)
__all__ = ('Sentence', 'SentenceReference')
class Sentence_data(Base, Versioned, DataMixin):
pass
class Sentence_files(Base, Versioned, FilesMixin):
pass
@implementer(interfaces.ISentence)
class Sentence(Base,
PolymorphicBaseMixin,
Versioned,
IdNameDescriptionMixin,
HasDataMixin,
HasFilesMixin):
"""Sentence of a language serving as example for some statement.
__all__ = ('Contributor',)
class Contributor_data(Base, Versioned, DataMixin):
pass
class Contributor_files(Base, Versioned, FilesMixin):
pass
@implementer(interfaces.IContributor)
class Contributor(Base,
PolymorphicBaseMixin,
Versioned,
IdNameDescriptionMixin,
HasDataMixin,
HasFilesMixin):
"""Creator of a contribution."""
__table_args__ = (UniqueConstraint('name'),)
url = Column(Unicode())
email = Column(String)
address = Column(Unicode)
def last_first(self):
if not self.name:
return ''
return '{0.last}, {0.first} {0.middle}'.format(HumanName(self.name)).strip()
__all__ = ('Sentence', 'SentenceReference')
class Sentence_data(Base, Versioned, DataMixin):
pass
class Sentence_files(Base, Versioned, FilesMixin):
pass
@implementer(interfaces.ISentence)
class Sentence(Base,
PolymorphicBaseMixin,
Versioned,
IdNameDescriptionMixin,
HasDataMixin,
HasFilesMixin):
"""Sentence of a language serving as example for some statement.
.. note::
Columns inherited from IdNameDescriptionMixin are interpreted as follows:
name: The text of the sentence in object language
description: A translation of the sentence
Columns with a name prefix of 'markup_' can be used to store data containing HTML
markup. These attributes should take precedence over their non-prefixed
counterparts when rendering a Sentence.
number = Column(Integer, doc='numerical value of the domain element')
"""the number is used to sort domain elements within the domain of one parameter"""
abbr = Column(Unicode, doc='abbreviated name')
"""abbreviated name, e.g. as label for map legends"""
def url(self, request):
return request.resource_url(self.parameter, _anchor='DE-' + self.id)
class Parameter_data(Base, Versioned, DataMixin):
pass
class Parameter_files(Base, Versioned, FilesMixin):
pass
@implementer(interfaces.IParameter)
class Parameter(Base,
PolymorphicBaseMixin,
Versioned,
IdNameDescriptionMixin,
HasDataMixin,
HasFilesMixin):
"""A measurable attribute of a language."""
__table_args__ = (UniqueConstraint('name'),)
domain = relationship(
__all__ = ('UnitDomainElement', 'UnitParameter')
class UnitDomainElement_data(Base, Versioned, DataMixin):
pass
class UnitDomainElement_files(Base, Versioned, FilesMixin):
pass
@implementer(interfaces.IUnitDomainElement)
class UnitDomainElement(Base,
PolymorphicBaseMixin,
Versioned,
IdNameDescriptionMixin,
HasDataMixin,
HasFilesMixin):
"""Domain element for the domain of a UnitParameter."""
__table_args__ = (
UniqueConstraint('unitparameter_pk', 'name'),
UniqueConstraint('unitparameter_pk', 'ord'),
)
unitparameter_pk = Column(Integer, ForeignKey('unitparameter.pk'), nullable=False)
ord = Column(Integer)
def url(self, request):
return request.resource_url(self.parameter, _anchor='DE-%s' % self.id)
"""Domain element for the domain of a UnitParameter."""
__table_args__ = (
UniqueConstraint('unitparameter_pk', 'name'),
UniqueConstraint('unitparameter_pk', 'ord'),
)
unitparameter_pk = Column(Integer, ForeignKey('unitparameter.pk'), nullable=False)
ord = Column(Integer)
def url(self, request):
return request.resource_url(self.parameter, _anchor='DE-%s' % self.id)
class UnitParameter_data(Base, Versioned, DataMixin):
pass
class UnitParameter_files(Base, Versioned, FilesMixin):
pass
@implementer(interfaces.IUnitParameter)
class UnitParameter(Base,
PolymorphicBaseMixin,
Versioned,
IdNameDescriptionMixin,
HasDataMixin,
HasFilesMixin):
"""A measurable attribute of a unit."""
def url(self, request):
return request.resource_url(self.parameter, _anchor='DE-%s' % self.id)
class UnitParameter_data(Base, Versioned, DataMixin):
pass
class UnitParameter_files(Base, Versioned, FilesMixin):
pass
@implementer(interfaces.IUnitParameter)
class UnitParameter(Base,
PolymorphicBaseMixin,
Versioned,
IdNameDescriptionMixin,
HasDataMixin,
HasFilesMixin):
"""A measurable attribute of a unit."""
domain = relationship(
'UnitDomainElement', backref='parameter', order_by=UnitDomainElement.id)
return ' with '.join(contribs)
class ContributionReference(Base, Versioned, HasSourceNotNullMixin):
"""Association table."""
__table_args__ = (
UniqueConstraint('contribution_pk', 'source_pk', 'description'),
)
contribution_pk = Column(Integer, ForeignKey('contribution.pk'), nullable=False)
contribution = relationship(Contribution, innerjoin=True, backref="references")
class ContributionContributor(Base, PolymorphicBaseMixin, Versioned):
"""Many-to-many association between contributors and contributions."""
__table_args__ = (UniqueConstraint('contribution_pk', 'contributor_pk'),)
contribution_pk = Column(Integer, ForeignKey('contribution.pk'), nullable=False)
contributor_pk = Column(Integer, ForeignKey('contributor.pk'), nullable=False)
# contributors are ordered.
ord = Column(Integer, default=1)
# we distinguish between primary and secondary (a.k.a. 'with ...') contributors.
primary = Column(Boolean, default=True)
contribution = relationship(
Contribution, innerjoin=True, backref='contributor_assocs')