def add(word): """ Adds a single word to the pipeline. """ from serapis import tasks message = {'word': word, 'hashslug': util.hashslug(word)} tasks.write_message('search', message) print("Added task '{}'".format(message['hashslug']))
def add_words(bucket, key): contents = config.s3.Object(bucket, key).get() words = contents['Body'].read().splitlines() added, skipped = set(), [] for term in words: term = clean_and_qualify_term(term) if term: slug = hashslug(term) if slug not in added: added.add(slug) message = {'word': term, 'hashslug': slug} tasks.write_message('search', message) else: skipped.append(term) else: skipped.append(term) print "Added {} terms, skipped {}".format(len(added), len(skipped))