def grep_search(search_terms, document_root):
    command = shlex.split('grep -Hir "%s" %s' % (search_terms, document_root))

    grep_process = subprocess.Popen(command, stdout=subprocess.PIPE,
                                    stderr=subprocess.PIPE)

    (output, error) = grep_process.communicate()

    if [0,1] not in grep_process.returncode:
        abort(500, "'%s' failed with error %d: %s %s" % (
                command, grep_process.returncode, output, error))

    results = collections.defaultdict(list)

    for match in output.split('\n'):
        if len(match) == 0:
            continue

        (filename, delim, line_text) = match.partition(':')

        file_extension = os.path.splitext(filename)[1]

        if file_extension not in markup_file_suffixes:
            continue

        filename = os.path.relpath(filename, document_root)

        results[filename].append(unicode(line_text, "utf8"))

    return results
dataset/ETHPy150Open alexras/markupserve/markupserve.py/grep_search/swapped operands of `not in`