Mercurial > hg > bitsytweet
changeset 6:3cb8ad35fe62
make a dummy front end
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Thu, 25 Nov 2010 13:07:37 -0800 |
parents | 50f77774a20a |
children | dfbb21128332 |
files | bitsytweet/__init__.py |
diffstat | 1 files changed, 36 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/bitsytweet/__init__.py Thu Jul 08 11:13:43 2010 -0700 +++ b/bitsytweet/__init__.py Thu Nov 25 13:07:37 2010 -0800 @@ -2,6 +2,7 @@ BitsyTweet """ +import sys import twitter class BitsyTweet(object): @@ -16,3 +17,38 @@ if blog_entry.privacy == 'public': # only tweet public blogs tweet = '%s : %s' % (blog_entry.snippet(), url) self.api.PostUpdate(tweet) + +def main(args=sys.argv[1:]): + """debugging front-end for BitstTweet""" + + usage = "%prog [options] tweet" + from optparse import OptionParser + parser = OptionParser(usage=usage) + parser.add_option('-u', '--username', + help='username') + parser.add_option('-p', '--password', + help='password') + options, args = parser.parse_args(args) + if not options.username: + parser.error('please provide a username') + if not options.password: + parser.error('please provide a password') + if not args: + parser.error('please provide a post') + + # get the tweeter + bitsytweet = BitsyTweet(None, options.username, options.password) + + # make a dummy class + class Dummy(object): + def __init__(self, tweet): + self.tweet = tweet + def snippet(self): + return self.tweet + blog_entry = Dummy(' '.join(args)) + + # tweet it + bitsytweet(blog_entry, 'http://k0s.org/blog') + +if __name__ == '__main__': + main()