Toptal-API
Toptal-API copied to clipboard
pip?
Plase make it installable with pip.
Just submitted package to PyPi. So you can now install with pip.
Is it a Python 2 or Python 3 project? I tried both but I got some errors.
Trying it in a Python 3 virtual environment:
$ toptal
Traceback (most recent call last):
File "/tmp/venv_Knr6K/venv/bin/toptal", line 7, in <module>
from toptal import main
File "/tmp/venv_Knr6K/venv/lib/python3.5/site-packages/toptal/__init__.py", line 1, in <module>
from Toptal import Toptal, Item, Freelencer
ImportError: No module named 'Toptal'
Trying it in a Python 2 virtual environment:
$ toptal
Traceback (most recent call last):
File "/tmp/venv_6Wd70/venv/bin/toptal", line 11, in <module>
sys.exit(main())
File "/tmp/venv_6Wd70/venv/lib/python2.7/site-packages/click/core.py", line 700, in __call__
return self.main(*args, **kwargs)
File "/tmp/venv_6Wd70/venv/lib/python2.7/site-packages/click/core.py", line 680, in main
rv = self.invoke(ctx)
File "/tmp/venv_6Wd70/venv/lib/python2.7/site-packages/click/core.py", line 873, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/tmp/venv_6Wd70/venv/lib/python2.7/site-packages/click/core.py", line 508, in invoke
return callback(*args, **kwargs)
File "/tmp/venv_6Wd70/venv/lib/python2.7/site-packages/toptal/__init__.py", line 46, in main
click.echo("Options:\n--newest Find the newest engineering blog posts \n--topic Search engineering blog posts by topic (backend, frontend, mobile, design, data science, database... \n--trending Find the trending engineering posts \n--search Search engineering blog posts by keyword", fg="red", bold=True)
TypeError: echo() got an unexpected keyword argument 'fg'
This is actually a Python 2 project, as specified in the setup.py. This error is caused by the click.echo() in the else case of main() in the init.py, this happens when you do not add option to the toptal command.
What happens when you add option to the toptal command? try commands like $toptal --newest=true ?
OK, it works. Well, if no argument is given, then print a short help of the options.
I also got a BeautifulSoup warning:
$ toptal --newest=true
/tmp/venv_6Wd70/venv/lib/python2.7/site-packages/bs4/__init__.py:166: UserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system ("html.parser"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently.
To get rid of this warning, change this:
BeautifulSoup([your markup])
to this:
BeautifulSoup([your markup], "html.parser")
markup_type=markup_type))
Newest engineering posts:
1. Rise Of Automated Trading: Machines Trading S&P 500
http://toptal.com/machine-learning/s-p-500-automated-trading
...
Python 3 support would be nice. Using the library "six" you can write code that runs on both Python 2 and Python 3. Or, you could rewrite it in Python 3, I don't think you should change a lot. I think Python 3 is a better choice for a new project.
The package is just updated in pypi, with the BeautifulSoup parser specified, and the click.echo() bug fixed. Now help info will show up when no option is given to the command.
Thanks for pointing out 👍
Thanks for the quick fix. I have another issue:
$ toptal --topic=python
Search result based on topic(python):
Traceback (most recent call last):
File "/tmp/venv_6Wd70/venv/bin/toptal", line 11, in <module>
sys.exit(main())
File "/tmp/venv_6Wd70/venv/lib/python2.7/site-packages/click/core.py", line 700, in __call__
return self.main(*args, **kwargs)
File "/tmp/venv_6Wd70/venv/lib/python2.7/site-packages/click/core.py", line 680, in main
rv = self.invoke(ctx)
File "/tmp/venv_6Wd70/venv/lib/python2.7/site-packages/click/core.py", line 873, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/tmp/venv_6Wd70/venv/lib/python2.7/site-packages/click/core.py", line 508, in invoke
return callback(*args, **kwargs)
File "/tmp/venv_6Wd70/venv/lib/python2.7/site-packages/toptal/__init__.py", line 35, in main
click.secho(str(i) + '. ' + items[i-1].title, fg="yellow", bold=True)
TypeError: cannot concatenate 'str' and 'builtin_function_or_method' objects
I figured out that I should use --search in this case but still, that error message is scary. Catch the exception and print some friendly message instead.
I just fixed it and had the exception handling added. Again, thanks for pointing this out. 👍 @jabbalaci