pubs/pubs/commands/websearch_cmd.py
Fabien C. Y. Benureau dc4e118c3c make utf8 citekeys possible in python 2.7. closes #28
This involved many changes, some side effects of the change include:
- remove of all `u"abc"` forms, in favor of
  `from __future__ import unicode_literals`. Their usage was
  inconsistent anyway, leading to problems when mixing with
  unicode content.
- improve the tests, to allow printing for usecase even when
  crashing. Should make future test easier. This is done with a
  rather hacky `StdIO` class in `p3`, but it works.
- for some reason, the skipped test for Python 2 seems to work
  now. While the previous point might seem related, it is not clear
  that this is actually the case.
2018-04-10 14:45:54 +09:00

25 lines
633 B
Python

from __future__ import unicode_literals
import webbrowser
from .. import p3
from ..uis import get_ui
def parser(subparsers, conf):
parser = subparsers.add_parser('websearch',
help="launch a search on Google Scholar")
parser.add_argument("search_string", nargs = '*',
help="the search query (anything googly is possible)")
return parser
def command(conf, args):
ui = get_ui()
search_string = args.search_string
url = ("https://scholar.google.fr/scholar?q=%s&lr="
% (p3.quote_plus(' '.join(search_string))))
webbrowser.open(url)