askhist_search.py
def build_searchstring(mandatory, optional):
    """Take in two lists of keywords and output a reddit-search string
    Mandatory keywords are those which must all occur in the post,
    whereas only one of the optional keywords must appear"""

    # I hate how this looks, but I don't see a much better way of doing it
    # DRY is going to get violated no matter what you do
    mandatory_words = "({})"
    if mandatory is not None:
        mandatory_words = mandatory_words.format(" AND ".join(mandatory))
    optional_words = "({})"
    if optional is not None:
        optional_words = optional_words.format(" OR ".join(optional))
        if mandatory is not None:
            return "{} AND {}".format(mandatory_words, optional_words)
        return optional_words
    return mandatory_words
Take in two lists of keywords and output a reddit-search string
    Mandatory keywords are those which must all occur in the post,
    whereas only one of the optional keywords must appear
Take in two lists of keywords and output a reddit-search string
Mandatory keywords are those which must all occur in the post,
whereas only one of the optional keywords must appear
Take in two lists of keywords and output a reddit - search string Mandatory keywords are those which must all occur in the post whereas only one of the optional keywords must appear
def build_searchstring(mandatory, optional):
    mandatory_words = "({})"
    if mandatory is not None:
        mandatory_words = mandatory_words.format(" AND ".join(mandatory))
    optional_words = "({})"
    if optional is not None:
        optional_words = optional_words.format(" OR ".join(optional))
        if mandatory is not None:
            return "{} AND {}".format(mandatory_words, optional_words)
        return optional_words
    return mandatory_words
def build_searchstring ( mandatory , optional ) : mandatory_words = "({})" if mandatory is not None : mandatory_words = mandatory_words . format ( " AND " . join ( mandatory ) ) optional_words = "({})" if optional is not None : optional_words = optional_words . format ( " OR " . join ( optional ) ) if mandatory is not None : return "{} AND {}" . format ( mandatory_words , optional_words ) return optional_words return mandatory_words
Take in two lists of keywords and output a reddit-search string
Mandatory keywords are those which must all occur in the post,
whereas only one of the optional keywords must appear
Take in two lists of keywords and output a reddit - search string Mandatory keywords are those which must all occur in the post whereas only one of the optional keywords must appear
"""Take in two lists of keywords and output a reddit-search string
    Mandatory keywords are those which must all occur in the post,
    whereas only one of the optional keywords must appear""" # I hate how this looks, but I don't see a much better way of doing it # DRY is going to get violated no matter what you do
mandatory
optional