Example #1
0
###############################################################################
# Driver for sanity checking and demonstration

if __name__=='__main__':
    import os
    import sys
    sys.path.append(os.getcwd())
    
    try:
        from libs.termcolor import termcolor
    except ImportError:
        print 'Failed to import libs. Are you calling the driver from the ',
        print 'project root? (cwd is %s)' % os.getcwd()
        exit(1)

    wordlist = get_wordlist()

    print 'Type a word to see if it\'s in the default wordlist:'
    while True:
        try:
            word = raw_input(' > ').lower()
        except (EOFError, KeyboardInterrupt):
            print
            break

        present = word in wordlist
        print termcolor.colored('%s is %s in the wordlist' %
                (word, '' if present else 'not'),
                'green' if present else 'red')
Example #2
0
    except ImportError:
        print 'Failed to import libs. Are you calling the driver from the ',
        print 'project root? (cwd is %s)' % os.getcwd()
        exit(1)

    import lists
    wordlist = lists.get_wordlist()

    print 'Input a pattern and a gutter to see the words that match it.'
    print '  usage: [pattern],[gutter]'

    while True:
        try:
            try:
                pattern, gutter = [i.strip() for i in
                                   raw_input(' > ').split(',')]
            except ValueError:
                print '  usage: [pattern],[gutter]'
                continue
        except (EOFError, KeyboardInterrupt):
            print
            break

        p = Pattern(pattern)
        words = p.find_matches(wordlist, gutter)
        if len(words) == 0:
            print termcolor.colored('No matches found', 'red')
        for word in words:
            print termcolor.colored(word, 'green')