def get_pronouns_by_subject(subject_pronoun):
"""
Given a subject pronoun (as a string), return the Pronouns object
that corresponds to that subject pronoun. This can be called with
strings like "he", "she", and "it".
If no Pronouns object is found that matches this subject pronoun, or
there are multiple Pronouns objects that match, a ValidationError is raised.
"""
try:
return Pronouns.query.filter_by(subject=subject_pronoun).one()
except NoResultFound:
raise ValidationError(
'No set of pronouns found for subject pronoun "{subject}"'.format(
subject=subject_pronoun
)
)
except MultipleResultsFound:
raise ValidationError(
'Multiple sets of pronouns found for subject pronoun '
'"{subject}". Use more specific filters.'.format(
subject=subject_pronoun
)
)
评论列表
文章目录