INNER CODE UNIT · Python
join_words
yezyilomo/django-restql · django_restql/fields.py:98
def join_words(words, many="are", single="is"):
word_list = ["`" + word + "`" for word in words]
if len(words) > 1:
sentence = " & ".join([", ".join(word_list[:-1]), word_list[-1]])
return "%s %s" % (many, sentence)
elif len(words) == 1:
return "%s %s" % (single, word_list[0])
return "%s %s" % (single, "[]")
if not set(create_ops).issubset(set(CREATE_OPERATIONS)):
msg = (
"Invalid create operation(s) at `%s`, Supported operations " +
join_words(CREATE_OPERATIONS)
) % "create_ops=%s" % create_ops
raise InvalidOperation(msg)
if not set(update_ops).issubset(set(UPDATE_OPERATIONS)):