diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2011-05-26 00:54:09 +0000 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net> | 2011-05-26 00:54:09 +0000 |
commit | d1182fa3293bfa75b81bc0928aef3ae0b1ee5eb5 (patch) | |
tree | ff636234f0770af4dec6a7b36f9e64f90f32a176 /JKTwitterBot/src/listwork.py | |
parent | 1b7d791670fb56b413ed4babb0e7024f6e5921a7 (diff) |
Added more status updates and committed my utilities for working with the lists
Diffstat (limited to 'JKTwitterBot/src/listwork.py')
-rw-r--r-- | JKTwitterBot/src/listwork.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/JKTwitterBot/src/listwork.py b/JKTwitterBot/src/listwork.py new file mode 100644 index 0000000..f0b48f0 --- /dev/null +++ b/JKTwitterBot/src/listwork.py @@ -0,0 +1,48 @@ +#!/usr/bin/python + +import pickle +import random + +def shuffle(name): + with open(name, 'rb') as f: + tweets = pickle.load(f) + + random.shuffle(tweets) + + with open(name, 'wb') as f: + pickle.dump(tweets, f) + +def add(name, fn): + run = True + + with open(name, 'rb') as f: + tweets = pickle.load(f) + + with open(fn, 'r') as f: + for line in f: + if len(line) < 130: + tweets.append(line.strip()) + + with open(name, 'wb') as f: + pickle.dump(tweets, f) + +def test(name): + run = True + i = 0 + oops = [] + + while run: + line = raw_input() + + if line == '.': + run = False + + else: + if len(line) > 130: + oops.append(i) + + i += 1 + + print oops + + |