예제 #1
0
 def validate_title(self, field):
     """
     If the title is already in use, refuse to add this one.
     """
     existing = set([simplify_text(c.title) for c in
         Category.query.filter_by(workspace=g.workspace).all() if c != self.edit_obj])
     if simplify_text(field.data) in existing:
         raise wtforms.ValidationError("You have an existing category with the same name")
예제 #2
0
파일: utils.py 프로젝트: sonhmai/hasjob
def get_word_bag(text):
    """
    Return a string containing all unique words in the given text, in alphabetical order.

    >>> get_word_bag("This is a piece\tof text with this extra bit!")
    'a bit extra is of piece text this with'
    """
    words = list(set(simplify_text(striptags(text)).split(' ')))
    words.sort()
    return " ".join(words)
예제 #3
0
파일: utils.py 프로젝트: hasgeek/hasjob
def get_word_bag(text):
    """
    Return a string containing all unique words in the given text, in alphabetical order.

    >>> get_word_bag("This is a piece\tof text with this extra bit!")
    'a bit extra is of piece text this with'
    """
    words = list(set(simplify_text(striptags(text)).split(' ')))
    words.sort()
    return " ".join(words)