howdoi-1.1.9/0000755€ŹâR€ŹâR0000000000012706106273014204 5ustar bgleitzman00000000000000howdoi-1.1.9/CHANGES.txt0000644€ŹâR€ŹâR0000000271712706106173016023 0ustar bgleitzman000000000000001.1.9 ------ - Fix issue with upload to PyPI 1.1.8 ------ - Fix colorization when HOWDOI_COLORIZE env variable is enabled - Fix certificate validation when SSL disabled 1.1.7 ------ - Add Localization support with HOWDOI_LOCALIZATION env variable (Currently only pt-br and en) 1.1.6 ------ - Updates for Python3 - Updates for caching 1.1.5 ------ - Updates for Python3 - Fix issues with cache - Allow disabling SSL when accessing Google 1.1.4 ------ - Added caching 1.1.3 ------ - Added fix to handle change in Google search page HTML - Updated Travis CI tests 1.1.2 ------ - Compatibility fixes for Python3.2 - Travis CI tests now being run for Python 2.6, 2.7, 3.2, and 3.3 1.1.1 ------ - Added message when question has no answer 1.1 ------ - Added multiple answers with -n/--num-answers flag - Added colorized output with -c/--color flag - Added answer link to the bottom of questions with -a/--all flag - Unit tests now managed through Travis CI 1.0 ------ - Added support for Python3 - Switched to the requests library instead of urllib2 - Project status changed to Production/Stable - Added troubleshooting steps to the README 0.2 ------ - Added sane flags - Now using ``/usr/bin/env python`` instead of ``/usr/bin/python`` - Updated README for brew installation instructions 0.1.2 ------ - Added Windows executable - Updated README for pip installation instructions 0.1.1 ------ - Added to PyPI 0.1 ------ - We're doing it live! howdoi-1.1.9/howdoi/0000755€ŹâR€ŹâR0000000000012706106273015475 5ustar bgleitzman00000000000000howdoi-1.1.9/howdoi/__init__.py0000644€ŹâR€ŹâR0000000002612706106202017574 0ustar bgleitzman00000000000000__version__ = '1.1.9' howdoi-1.1.9/howdoi/howdoi.py0000755€ŹâR€ŹâR0000002053212706103625017343 0ustar bgleitzman00000000000000#!/usr/bin/env python ###################################################### # # howdoi - instant coding answers via the command line # written by Benjamin Gleitzman (gleitz@mit.edu) # inspired by Rich Jones (rich@anomos.info) # ###################################################### import argparse import glob import os import random import re import requests import requests_cache import sys from . import __version__ from pygments import highlight from pygments.lexers import guess_lexer, get_lexer_by_name from pygments.formatters.terminal import TerminalFormatter from pygments.util import ClassNotFound from pyquery import PyQuery as pq from requests.exceptions import ConnectionError from requests.exceptions import SSLError # Handle imports for Python 2 and 3 if sys.version < '3': import codecs from urllib import quote as url_quote from urllib import getproxies # Handling Unicode: http://stackoverflow.com/a/6633040/305414 def u(x): return codecs.unicode_escape_decode(x)[0] else: from urllib.request import getproxies from urllib.parse import quote as url_quote def u(x): return x if os.getenv('HOWDOI_DISABLE_SSL'): # Set http instead of https SEARCH_URL = 'http://www.google.com/search?q=site:{0}%20{1}' VERIFY_SSL_CERTIFICATE = False else: SEARCH_URL = 'https://www.google.com/search?q=site:{0}%20{1}' VERIFY_SSL_CERTIFICATE = True URL = os.getenv('HOWDOI_URL') or 'stackoverflow.com' USER_AGENTS = ('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:11.0) Gecko/20100101 Firefox/11.0', 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100 101 Firefox/22.0', 'Mozilla/5.0 (Windows NT 6.1; rv:11.0) Gecko/20100101 Firefox/11.0', ('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.5 (KHTML, like Gecko) ' 'Chrome/19.0.1084.46 Safari/536.5'), ('Mozilla/5.0 (Windows; Windows NT 6.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.46' 'Safari/536.5'), ) ANSWER_HEADER = u('--- Answer {0} ---\n{1}') NO_ANSWER_MSG = '< no answer given >' XDG_CACHE_DIR = os.environ.get('XDG_CACHE_HOME', os.path.join(os.path.expanduser('~'), '.cache')) CACHE_DIR = os.path.join(XDG_CACHE_DIR, 'howdoi') CACHE_FILE = os.path.join(CACHE_DIR, 'cache{0}'.format( sys.version_info[0] if sys.version_info[0] == 3 else '')) def get_proxies(): proxies = getproxies() filtered_proxies = {} for key, value in proxies.items(): if key.startswith('http'): if not value.startswith('http'): filtered_proxies[key] = 'http://%s' % value else: filtered_proxies[key] = value return filtered_proxies def _get_result(url): try: return requests.get(url, headers={'User-Agent': random.choice(USER_AGENTS)}, proxies=get_proxies(), verify=VERIFY_SSL_CERTIFICATE).text except requests.exceptions.SSLError as e: print('[ERROR] Encountered an SSL Error. Try using HTTP instead of ' 'HTTPS by setting the environment variable "HOWDOI_DISABLE_SSL".\n') raise e def _get_links(query): result = _get_result(SEARCH_URL.format(URL, url_quote(query))) html = pq(result) return [a.attrib['href'] for a in html('.l')] or \ [a.attrib['href'] for a in html('.r')('a')] def get_link_at_pos(links, position): if not links: return False if len(links) >= position: link = links[position - 1] else: link = links[-1] return link def _format_output(code, args): if not args['color']: return code lexer = None # try to find a lexer using the StackOverflow tags # or the query arguments for keyword in args['query'].split() + args['tags']: try: lexer = get_lexer_by_name(keyword) break except ClassNotFound: pass # no lexer found above, use the guesser if not lexer: try: lexer = guess_lexer(code) except ClassNotFound: return code return highlight(code, lexer, TerminalFormatter(bg='dark')) def _is_question(link): return re.search('questions/\d+/', link) def _get_questions(links): return [link for link in links if _is_question(link)] def _get_answer(args, links): links = _get_questions(links) link = get_link_at_pos(links, args['pos']) if not link: return False if args.get('link'): return link page = _get_result(link + '?answertab=votes') html = pq(page) first_answer = html('.answer').eq(0) instructions = first_answer.find('pre') or first_answer.find('code') args['tags'] = [t.text for t in html('.post-tag')] if not instructions and not args['all']: text = first_answer.find('.post-text').eq(0).text() elif args['all']: texts = [] for html_tag in first_answer.items('.post-text > *'): current_text = html_tag.text() if current_text: if html_tag[0].tag in ['pre', 'code']: texts.append(_format_output(current_text, args)) else: texts.append(current_text) texts.append('\n---\nAnswer from {0}'.format(link)) text = '\n'.join(texts) else: text = _format_output(instructions.eq(0).text(), args) if text is None: text = NO_ANSWER_MSG text = text.strip() return text def _get_instructions(args): links = _get_links(args['query']) if not links: return False answers = [] append_header = args['num_answers'] > 1 initial_position = args['pos'] for answer_number in range(args['num_answers']): current_position = answer_number + initial_position args['pos'] = current_position answer = _get_answer(args, links) if not answer: continue if append_header: answer = ANSWER_HEADER.format(current_position, answer) answer += '\n' answers.append(answer) return '\n'.join(answers) def _enable_cache(): if not os.path.exists(CACHE_DIR): os.makedirs(CACHE_DIR) requests_cache.install_cache(CACHE_FILE) def _clear_cache(): for cache in glob.glob('{0}*'.format(CACHE_FILE)): os.remove(cache) def howdoi(args): args['query'] = ' '.join(args['query']).replace('?', '') try: return _get_instructions(args) or 'Sorry, couldn\'t find any help with that topic\n' except (ConnectionError, SSLError): return 'Failed to establish network connection\n' def get_parser(): parser = argparse.ArgumentParser(description='instant coding answers via the command line') parser.add_argument('query', metavar='QUERY', type=str, nargs='*', help='the question to answer') parser.add_argument('-p', '--pos', help='select answer in specified position (default: 1)', default=1, type=int) parser.add_argument('-a', '--all', help='display the full text of the answer', action='store_true') parser.add_argument('-l', '--link', help='display only the answer link', action='store_true') parser.add_argument('-c', '--color', help='enable colorized output', action='store_true') parser.add_argument('-n', '--num-answers', help='number of answers to return', default=1, type=int) parser.add_argument('-C', '--clear-cache', help='clear the cache', action='store_true') parser.add_argument('-v', '--version', help='displays the current version of howdoi', action='store_true') return parser def command_line_runner(): parser = get_parser() args = vars(parser.parse_args()) if args['version']: print(__version__) return if args['clear_cache']: _clear_cache() print('Cache cleared successfully') return if not args['query']: parser.print_help() return # enable the cache if user doesn't want it to be disabled if not os.getenv('HOWDOI_DISABLE_CACHE'): _enable_cache() if os.getenv('HOWDOI_COLORIZE'): args['color'] = True if sys.version < '3': print(howdoi(args).encode('utf-8', 'ignore')) else: print(howdoi(args)) if __name__ == '__main__': command_line_runner() howdoi-1.1.9/howdoi.egg-info/0000755€ŹâR€ŹâR0000000000012706106273017167 5ustar bgleitzman00000000000000howdoi-1.1.9/howdoi.egg-info/dependency_links.txt0000644€ŹâR€ŹâR0000000000112706106273023235 0ustar bgleitzman00000000000000 howdoi-1.1.9/howdoi.egg-info/entry_points.txt0000644€ŹâR€ŹâR0000000007612706106273022470 0ustar bgleitzman00000000000000[console_scripts] howdoi = howdoi.howdoi:command_line_runner howdoi-1.1.9/howdoi.egg-info/PKG-INFO0000644€ŹâR€ŹâR0000002124512706106273020270 0ustar bgleitzman00000000000000Metadata-Version: 1.1 Name: howdoi Version: 1.1.9 Summary: Instant coding answers via the command line Home-page: https://github.com/gleitz/howdoi Author: Benjamin Gleitzman Author-email: gleitz@mit.edu License: MIT Description: howdoi ==================================================== .. image:: http://imgs.xkcd.com/comics/tar.png :target: https://xkcd.com/1168/ instant coding answers via the command line ------------------------------------------- .. image:: https://secure.travis-ci.org/gleitz/howdoi.png?branch=master :target: https://travis-ci.org/gleitz/howdoi .. image:: https://img.shields.io/pypi/dm/howdoi.svg :target: https://pypi.python.org/pypi/howdoi Are you a hack programmer? Do you find yourself constantly Googling for how to do basic programing tasks? Suppose you want to know how to format a date in bash. Why open your browser and read through blogs (risking major distraction) when you can simply stay in the console and ask howdoi: :: $ howdoi format date bash > DATE=`date +%Y-%m-%d` howdoi will answer all sorts of queries: :: $ howdoi print stack trace python > import traceback > > try: > 1/0 > except: > print '>>> traceback <<<' > traceback.print_exc() > print '>>> end of traceback <<<' > traceback.print_exc() $ howdoi convert mp4 to animated gif > video=/path/to/video.avi > outdir=/path/to/output.gif > mplayer "$video" \ > -ao null \ > -ss "00:01:00" \ # starting point > -endpos 10 \ # duration in second > -vo gif89a:fps=13:output=$outdir \ > -vf scale=240:180 $ howdoi create tar archive > tar -cf backup.tar --exclude "www/subf3" www Installation ------------ :: pip install howdoi or :: pip install git+https://github.com/gleitz/howdoi.git#egg=howdoi or :: brew install https://raw.github.com/gleitz/howdoi/master/howdoi.rb or :: python setup.py install Usage ----- :: usage: howdoi.py [-h] [-p POS] [-a] [-l] [-c] [-n NUM_ANSWERS] [-C] [-v] QUERY [QUERY ...] instant coding answers via the command line positional arguments: QUERY the question to answer optional arguments: -h, --help show this help message and exit -p POS, --pos POS select answer in specified position (default: 1) -a, --all display the full text of the answer -l, --link display only the answer link -c, --color enable colorized output -n NUM_ANSWERS, --num-answers NUM_ANSWERS number of answers to return -C, --clear-cache clear the cache -v, --version displays the current version of howdoi Author ------ - Benjamin Gleitzman (`@gleitz `_) Notes ----- - Works with Python2 and Python3 - A standalone Windows executable with the howdoi application `is available here `_. - An Alfred Workflow for howdoi can be found at `http://blog.gleitzman.com/post/48539944559/howdoi-alfred-even-more-instant-answers `_. - Slack integration available through `slack-howdoi `_. - Howdoi uses a cache for faster access to previous questions. Caching functionality can be disabled by setting the HOWDOI_DISABLE_CACHE environment variable. The cache is stored in `~/.cache/howdoi`. - You can set the HOWDOI_URL environment variable to change the source url for answers (default: stackoverflow.com). Other options include `serverfault.com` or `pt.stackoverflow.com`. Here's the `full list `_. - Setting the HOWDOI_COLORIZE environment variable will colorize the output by default. - Special thanks to Rich Jones (`@miserlou `_) for the idea. Development ----------- - Checkout the repo - Run `python -m howdoi.howdoi QUERY` (if you try running `python howdoi/howdoi.py` you my get `ValueError: Attempted relative import in non-package`). Troubleshooting --------------- You might get the following error when installing with Homebrew: :: ==> python setup.py install http://peak.telecommunity.com/EasyInstall.html Please make the appropriate changes for your system and try again. Fix the error by executing the following command: :: sudo chmod -R go+w /Library/Python/2.7/site-packages/ An official lxml for python 3.3+ for windows has not yet been released. You may get an error while installing. Try and install an unofficial binary for lxml from :: http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml News ==== 1.1.9 ------ - Fix issue with upload to PyPI 1.1.8 ------ - Fix colorization when HOWDOI_COLORIZE env variable is enabled - Fix certificate validation when SSL disabled 1.1.7 ------ - Add Localization support with HOWDOI_LOCALIZATION env variable (Currently only pt-br and en) 1.1.6 ------ - Updates for Python3 - Updates for caching 1.1.5 ------ - Updates for Python3 - Fix issues with cache - Allow disabling SSL when accessing Google 1.1.4 ------ - Added caching 1.1.3 ------ - Added fix to handle change in Google search page HTML - Updated Travis CI tests 1.1.2 ------ - Compatibility fixes for Python3.2 - Travis CI tests now being run for Python 2.6, 2.7, 3.2, and 3.3 1.1.1 ------ - Added message when question has no answer 1.1 ------ - Added multiple answers with -n/--num-answers flag - Added colorized output with -c/--color flag - Added answer link to the bottom of questions with -a/--all flag - Unit tests now managed through Travis CI 1.0 ------ - Added support for Python3 - Switched to the requests library instead of urllib2 - Project status changed to Production/Stable - Added troubleshooting steps to the README 0.2 ------ - Added sane flags - Now using ``/usr/bin/env python`` instead of ``/usr/bin/python`` - Updated README for brew installation instructions 0.1.2 ------ - Added Windows executable - Updated README for pip installation instructions 0.1.1 ------ - Added to PyPI 0.1 ------ - We're doing it live! Keywords: howdoi help console command line answer Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Console Classifier: Intended Audience :: Developers Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.2 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Topic :: Documentation howdoi-1.1.9/howdoi.egg-info/requires.txt0000644€ŹâR€ŹâR0000000005112706106273021563 0ustar bgleitzman00000000000000pyquery pygments requests requests-cache howdoi-1.1.9/howdoi.egg-info/SOURCES.txt0000644€ŹâR€ŹâR0000000040512706106273021052 0ustar bgleitzman00000000000000CHANGES.txt MANIFEST.in README.rst setup.py howdoi/__init__.py howdoi/howdoi.py howdoi.egg-info/PKG-INFO howdoi.egg-info/SOURCES.txt howdoi.egg-info/dependency_links.txt howdoi.egg-info/entry_points.txt howdoi.egg-info/requires.txt howdoi.egg-info/top_level.txthowdoi-1.1.9/howdoi.egg-info/top_level.txt0000644€ŹâR€ŹâR0000000000712706106273021716 0ustar bgleitzman00000000000000howdoi howdoi-1.1.9/MANIFEST.in0000644€ŹâR€ŹâR0000000002312530402433015725 0ustar bgleitzman00000000000000include CHANGES.txthowdoi-1.1.9/PKG-INFO0000644€ŹâR€ŹâR0000002124512706106273015305 0ustar bgleitzman00000000000000Metadata-Version: 1.1 Name: howdoi Version: 1.1.9 Summary: Instant coding answers via the command line Home-page: https://github.com/gleitz/howdoi Author: Benjamin Gleitzman Author-email: gleitz@mit.edu License: MIT Description: howdoi ==================================================== .. image:: http://imgs.xkcd.com/comics/tar.png :target: https://xkcd.com/1168/ instant coding answers via the command line ------------------------------------------- .. image:: https://secure.travis-ci.org/gleitz/howdoi.png?branch=master :target: https://travis-ci.org/gleitz/howdoi .. image:: https://img.shields.io/pypi/dm/howdoi.svg :target: https://pypi.python.org/pypi/howdoi Are you a hack programmer? Do you find yourself constantly Googling for how to do basic programing tasks? Suppose you want to know how to format a date in bash. Why open your browser and read through blogs (risking major distraction) when you can simply stay in the console and ask howdoi: :: $ howdoi format date bash > DATE=`date +%Y-%m-%d` howdoi will answer all sorts of queries: :: $ howdoi print stack trace python > import traceback > > try: > 1/0 > except: > print '>>> traceback <<<' > traceback.print_exc() > print '>>> end of traceback <<<' > traceback.print_exc() $ howdoi convert mp4 to animated gif > video=/path/to/video.avi > outdir=/path/to/output.gif > mplayer "$video" \ > -ao null \ > -ss "00:01:00" \ # starting point > -endpos 10 \ # duration in second > -vo gif89a:fps=13:output=$outdir \ > -vf scale=240:180 $ howdoi create tar archive > tar -cf backup.tar --exclude "www/subf3" www Installation ------------ :: pip install howdoi or :: pip install git+https://github.com/gleitz/howdoi.git#egg=howdoi or :: brew install https://raw.github.com/gleitz/howdoi/master/howdoi.rb or :: python setup.py install Usage ----- :: usage: howdoi.py [-h] [-p POS] [-a] [-l] [-c] [-n NUM_ANSWERS] [-C] [-v] QUERY [QUERY ...] instant coding answers via the command line positional arguments: QUERY the question to answer optional arguments: -h, --help show this help message and exit -p POS, --pos POS select answer in specified position (default: 1) -a, --all display the full text of the answer -l, --link display only the answer link -c, --color enable colorized output -n NUM_ANSWERS, --num-answers NUM_ANSWERS number of answers to return -C, --clear-cache clear the cache -v, --version displays the current version of howdoi Author ------ - Benjamin Gleitzman (`@gleitz `_) Notes ----- - Works with Python2 and Python3 - A standalone Windows executable with the howdoi application `is available here `_. - An Alfred Workflow for howdoi can be found at `http://blog.gleitzman.com/post/48539944559/howdoi-alfred-even-more-instant-answers `_. - Slack integration available through `slack-howdoi `_. - Howdoi uses a cache for faster access to previous questions. Caching functionality can be disabled by setting the HOWDOI_DISABLE_CACHE environment variable. The cache is stored in `~/.cache/howdoi`. - You can set the HOWDOI_URL environment variable to change the source url for answers (default: stackoverflow.com). Other options include `serverfault.com` or `pt.stackoverflow.com`. Here's the `full list `_. - Setting the HOWDOI_COLORIZE environment variable will colorize the output by default. - Special thanks to Rich Jones (`@miserlou `_) for the idea. Development ----------- - Checkout the repo - Run `python -m howdoi.howdoi QUERY` (if you try running `python howdoi/howdoi.py` you my get `ValueError: Attempted relative import in non-package`). Troubleshooting --------------- You might get the following error when installing with Homebrew: :: ==> python setup.py install http://peak.telecommunity.com/EasyInstall.html Please make the appropriate changes for your system and try again. Fix the error by executing the following command: :: sudo chmod -R go+w /Library/Python/2.7/site-packages/ An official lxml for python 3.3+ for windows has not yet been released. You may get an error while installing. Try and install an unofficial binary for lxml from :: http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml News ==== 1.1.9 ------ - Fix issue with upload to PyPI 1.1.8 ------ - Fix colorization when HOWDOI_COLORIZE env variable is enabled - Fix certificate validation when SSL disabled 1.1.7 ------ - Add Localization support with HOWDOI_LOCALIZATION env variable (Currently only pt-br and en) 1.1.6 ------ - Updates for Python3 - Updates for caching 1.1.5 ------ - Updates for Python3 - Fix issues with cache - Allow disabling SSL when accessing Google 1.1.4 ------ - Added caching 1.1.3 ------ - Added fix to handle change in Google search page HTML - Updated Travis CI tests 1.1.2 ------ - Compatibility fixes for Python3.2 - Travis CI tests now being run for Python 2.6, 2.7, 3.2, and 3.3 1.1.1 ------ - Added message when question has no answer 1.1 ------ - Added multiple answers with -n/--num-answers flag - Added colorized output with -c/--color flag - Added answer link to the bottom of questions with -a/--all flag - Unit tests now managed through Travis CI 1.0 ------ - Added support for Python3 - Switched to the requests library instead of urllib2 - Project status changed to Production/Stable - Added troubleshooting steps to the README 0.2 ------ - Added sane flags - Now using ``/usr/bin/env python`` instead of ``/usr/bin/python`` - Updated README for brew installation instructions 0.1.2 ------ - Added Windows executable - Updated README for pip installation instructions 0.1.1 ------ - Added to PyPI 0.1 ------ - We're doing it live! Keywords: howdoi help console command line answer Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Console Classifier: Intended Audience :: Developers Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.2 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Topic :: Documentation howdoi-1.1.9/README.rst0000644€ŹâR€ŹâR0000001100012620141764015662 0ustar bgleitzman00000000000000howdoi ==================================================== .. image:: http://imgs.xkcd.com/comics/tar.png :target: https://xkcd.com/1168/ instant coding answers via the command line ------------------------------------------- .. image:: https://secure.travis-ci.org/gleitz/howdoi.png?branch=master :target: https://travis-ci.org/gleitz/howdoi .. image:: https://img.shields.io/pypi/dm/howdoi.svg :target: https://pypi.python.org/pypi/howdoi Are you a hack programmer? Do you find yourself constantly Googling for how to do basic programing tasks? Suppose you want to know how to format a date in bash. Why open your browser and read through blogs (risking major distraction) when you can simply stay in the console and ask howdoi: :: $ howdoi format date bash > DATE=`date +%Y-%m-%d` howdoi will answer all sorts of queries: :: $ howdoi print stack trace python > import traceback > > try: > 1/0 > except: > print '>>> traceback <<<' > traceback.print_exc() > print '>>> end of traceback <<<' > traceback.print_exc() $ howdoi convert mp4 to animated gif > video=/path/to/video.avi > outdir=/path/to/output.gif > mplayer "$video" \ > -ao null \ > -ss "00:01:00" \ # starting point > -endpos 10 \ # duration in second > -vo gif89a:fps=13:output=$outdir \ > -vf scale=240:180 $ howdoi create tar archive > tar -cf backup.tar --exclude "www/subf3" www Installation ------------ :: pip install howdoi or :: pip install git+https://github.com/gleitz/howdoi.git#egg=howdoi or :: brew install https://raw.github.com/gleitz/howdoi/master/howdoi.rb or :: python setup.py install Usage ----- :: usage: howdoi.py [-h] [-p POS] [-a] [-l] [-c] [-n NUM_ANSWERS] [-C] [-v] QUERY [QUERY ...] instant coding answers via the command line positional arguments: QUERY the question to answer optional arguments: -h, --help show this help message and exit -p POS, --pos POS select answer in specified position (default: 1) -a, --all display the full text of the answer -l, --link display only the answer link -c, --color enable colorized output -n NUM_ANSWERS, --num-answers NUM_ANSWERS number of answers to return -C, --clear-cache clear the cache -v, --version displays the current version of howdoi Author ------ - Benjamin Gleitzman (`@gleitz `_) Notes ----- - Works with Python2 and Python3 - A standalone Windows executable with the howdoi application `is available here `_. - An Alfred Workflow for howdoi can be found at `http://blog.gleitzman.com/post/48539944559/howdoi-alfred-even-more-instant-answers `_. - Slack integration available through `slack-howdoi `_. - Howdoi uses a cache for faster access to previous questions. Caching functionality can be disabled by setting the HOWDOI_DISABLE_CACHE environment variable. The cache is stored in `~/.cache/howdoi`. - You can set the HOWDOI_URL environment variable to change the source url for answers (default: stackoverflow.com). Other options include `serverfault.com` or `pt.stackoverflow.com`. Here's the `full list `_. - Setting the HOWDOI_COLORIZE environment variable will colorize the output by default. - Special thanks to Rich Jones (`@miserlou `_) for the idea. Development ----------- - Checkout the repo - Run `python -m howdoi.howdoi QUERY` (if you try running `python howdoi/howdoi.py` you my get `ValueError: Attempted relative import in non-package`). Troubleshooting --------------- You might get the following error when installing with Homebrew: :: ==> python setup.py install http://peak.telecommunity.com/EasyInstall.html Please make the appropriate changes for your system and try again. Fix the error by executing the following command: :: sudo chmod -R go+w /Library/Python/2.7/site-packages/ An official lxml for python 3.3+ for windows has not yet been released. You may get an error while installing. Try and install an unofficial binary for lxml from :: http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml howdoi-1.1.9/setup.cfg0000644€ŹâR€ŹâR0000000007312706106273016025 0ustar bgleitzman00000000000000[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 howdoi-1.1.9/setup.py0000644€ŹâR€ŹâR0000000360212620142000015676 0ustar bgleitzman00000000000000#!/usr/bin/env python from setuptools import setup, find_packages import howdoi import os def extra_dependencies(): import sys ret = [] if sys.version_info < (2, 7): ret.append('argparse') return ret def read(*names): values = dict() extensions = ['.txt', '.rst'] for name in names: value = '' for extension in extensions: filename = name + extension if os.path.isfile(filename): value = open(name + extension).read() break values[name] = value return values long_description = """ %(README)s News ==== %(CHANGES)s """ % read('README', 'CHANGES') setup( name='howdoi', version=howdoi.__version__, description='Instant coding answers via the command line', long_description=long_description, classifiers=[ "Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Developers", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: Documentation", ], keywords='howdoi help console command line answer', author='Benjamin Gleitzman', author_email='gleitz@mit.edu', maintainer='Benjamin Gleitzman', maintainer_email='gleitz@mit.edu', url='https://github.com/gleitz/howdoi', license='MIT', packages=find_packages(), entry_points={ 'console_scripts': [ 'howdoi = howdoi.howdoi:command_line_runner', ] }, install_requires=[ 'pyquery', 'pygments', 'requests', 'requests-cache' ] + extra_dependencies(), )