From c1fa7c947ef04c08c5ad03fc21187dc422981b49 Mon Sep 17 00:00:00 2001 From: Orakaro Date: Sat, 7 Jun 2014 15:51:59 +0900 Subject: [PATCH] fix argparse --- README.md | 5 +++-- README.rst | 5 +++-- rainbowstream/rainbow.py | 25 +++++++++++++------------ setup.py | 2 +- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 5be9245..3463819 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,10 @@ rainbow ``` and see your stream. -In the case you want to see photos directly in terminal, the command is +I shipped a feature which can display **tweet's images directly on terminal**. +You can try it with: ```bash -rainbow -img 1 # Or rainbow --image 1 +rainbow -iot # Or rainbow --image-on-term ``` In the first time you will be asked for authorization of Rainbow Stream app at Twitter. diff --git a/README.rst b/README.rst index 4e0516d..738c1f9 100644 --- a/README.rst +++ b/README.rst @@ -39,11 +39,12 @@ Just type and see your stream. -In the case you want to see photos directly in terminal, the command is +I shipped a feature which can display **tweet's images directly on terminal**. +You can try it with: .. code:: bash - rainbow -img 1 # Or rainbow --image 1 + rainbow -iot # Or rainbow --image-on-term In the first time you will be asked for authorization of Rainbow Stream app at Twitter. Just click the “Authorize access” button and paste PIN diff --git a/rainbowstream/rainbow.py b/rainbowstream/rainbow.py index b400529..73af665 100644 --- a/rainbowstream/rainbow.py +++ b/rainbowstream/rainbow.py @@ -49,7 +49,7 @@ cmdset = [ ] -def draw(t, imgflg = 0, keyword=None, fil=[], ig=[]): +def draw(t, iot=False, keyword=None, fil=[], ig=[]): """ Draw the rainbow """ @@ -145,7 +145,7 @@ def draw(t, imgflg = 0, keyword=None, fil=[], ig=[]): printNicely(line3) # Display Image - if imgflg and media_url: + if iot and media_url: for mu in media_url: response = requests.get(mu) image_to_display(StringIO(response.content)) @@ -183,9 +183,10 @@ def parse_arguments(): '--ignore', help='Ignore specific screen_name.') parser.add_argument( - '-img', - '--image', - help='Display all photo on terminal.') + '-iot', + '--image-on-term', + action='store_true', + help='Display all image on terminal.') return parser.parse_args() @@ -294,7 +295,7 @@ def home(): if g['stuff'].isdigit(): num = g['stuff'] for tweet in reversed(t.statuses.home_timeline(count=num)): - draw(t=tweet, imgflg=g['image']) + draw(t=tweet, iot=g['iot']) printNicely('') @@ -310,7 +311,7 @@ def view(): except: num = HOME_TWEET_NUM for tweet in reversed(t.statuses.user_timeline(count=num, screen_name=user[1:])): - draw(t=tweet, imgflg=g['image']) + draw(t=tweet, iot=g['iot']) printNicely('') else: printNicely(red('A name should begin with a \'@\'')) @@ -347,7 +348,7 @@ def favorite(): tid = db.rainbow_query(id)[0].tweet_id t.favorites.create(_id=tid, include_entities=False) printNicely(green('Favorited.')) - draw(t.statuses.show(id=tid), imgflg=g['image']) + draw(t.statuses.show(id=tid), iot=g['iot']) except: printNicely(red('Omg some syntax is wrong.')) @@ -392,7 +393,7 @@ def unfavorite(): tid = db.rainbow_query(id)[0].tweet_id t.favorites.destroy(_id=tid) printNicely(green('Okay it\'s unfavorited.')) - draw(t.statuses.show(id=tid), imgflg=g['image']) + draw(t.statuses.show(id=tid), iot=g['iot']) except: printNicely(red('Sorry I can\'t unfavorite this tweet for you.')) @@ -409,7 +410,7 @@ def search(): printNicely('Newest tweets:') for i in reversed(xrange(SEARCH_MAX_RECORD)): draw(t=rel[i], - imgflg=g['image'], + iot=g['iot'], keyword=g['stuff'].strip()[1:]) printNicely('') else: @@ -690,7 +691,7 @@ def stream(domain, args, name='Rainbow Stream'): elif tweet.get('text'): draw( t=tweet, - imgflg=args.image, + iot=args.image_on_term, keyword=args.track_keywords, fil=args.filter, ig=args.ignore, @@ -712,5 +713,5 @@ def fly(): g['reset'] = True g['prefix'] = True g['stream_pid'] = p.pid - g['image'] = args.image + g['iot'] = args.image_on_term listen() \ No newline at end of file diff --git a/setup.py b/setup.py index e4b48b0..5cf9afd 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -version = '0.0.2' +version = '0.0.3' install_requires = [ "SQLAlchemy", -- 2.25.1