def get_pronouns_by_filters(filters):
"""
Given a dictionary of pronoun filters, return the Pronouns object
that corresponds to those pronouns pronoun. Some examples:
{"subject": "he"}
{"subject": "they", "reflexive": "themself"}
{"subject": "they", "reflexive": "themselves"}
{"possessive": "hers"}
If no Pronouns object is found that matches these filters, or
there are multiple Pronouns objects that match, a ValidationError is raised.
"""
try:
return Pronouns.query.filter_by(**filters).one()
except NoResultFound:
raise ValidationError(
"No set of pronouns found for filters."
)
except MultipleResultsFound:
raise ValidationError(
"Multiple sets of pronouns found. Use more specific filters."
)
评论列表
文章目录