-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #455 Add Image/Video search support for Parsijoo #449
Conversation
62e7735
to
aa55eca
Compare
Codecov Report
@@ Coverage Diff @@
## master #449 +/- ##
==========================================
- Coverage 85.26% 85.01% -0.26%
==========================================
Files 28 28
Lines 794 834 +40
==========================================
+ Hits 677 709 +32
- Misses 117 125 +8
Continue to review full report at Codecov.
|
aa55eca
to
5b60b9f
Compare
…t for Parsijoo
5b60b9f
to
70899f8
Compare
.travis.yml
Outdated
@@ -9,7 +9,7 @@ install: | |||
- pip install -r requirements.txt | |||
|
|||
before_script: | |||
- flake8 . --count --max-complexity=15 --show-source --statistics | |||
- flake8 . --count --max-complexity=16 --show-source --statistics --max-line-length=100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to go back to violating PEP8 line length?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we refactor to reduce McCabe complexity?
app/server.py
Outdated
from scrapers import feed_gen, scrapers | ||
except Exception as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be going in the wrong direction. From PEP8: "When catching exceptions, mention specific exceptions whenever possible". Also, why create an unused variable (e)? Linters will properly complain.
@cclauss @realslimshanky @vaibhavsingh97 Please review. |
app/scrapers/generalized.py
Outdated
if urls == []: | ||
return "No video with this Keyword" | ||
else: | ||
return urls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we just do return urls or "No video with this Keyword" because all other falsey values are just as dangerous as an empty list.
app/scrapers/__init__.py
Outdated
@@ -42,6 +42,10 @@ def feed_gen(query, engine, count=10, qtype=''): | |||
engine = old_names.get(engine, engine) | |||
if engine in ('quora', 'youtube'): | |||
urls = scrapers[engine].search_without_count(query) | |||
elif (engine in ['parsijoo']) and (qtype == 'isch'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elif engine in ['parsijoo'] and qtype == 'isch': # Lose the parens... this is not JavaScript.
app/scrapers/__init__.py
Outdated
@@ -42,9 +42,9 @@ def feed_gen(query, engine, count=10, qtype=''): | |||
engine = old_names.get(engine, engine) | |||
if engine in ('quora', 'youtube'): | |||
urls = scrapers[engine].search_without_count(query) | |||
elif (engine in ['parsijoo']) and (qtype == 'isch'): | |||
elif engine in ('parsijoo') and qtype == 'isch': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
('parsijoo') is not a tuple, it is a str. ('parsijoo', ) is a tuple. However the test still works as expected.
$ python3 -c "print(type(('parsijoo')), type(('parsijoo', )))"
app/scrapers/parsijoo.py
Outdated
[[url1], [url2], ...] | ||
""" | ||
urls = [] | ||
for div in soup.findAll('div', attrs={'class': 'image-container overflow'}): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for div in soup.find_all('div', class_='image-container overflow'): # for PEP8 compatibility
@realslimshanky @cclauss I think now you can approve the PR. |
@bhaveshAn please squash your commits. |
Will squash after final approvals of PRs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flake8 remove --max-line-length=100
""" | ||
urls = [] | ||
for div in \ | ||
soup.findAll('div', attrs={'class': 'image-container overflow'}): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flake8 remove --max-line-length=100
Can't be done to for this reason. Its exceeding the default max-line-length
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reformat as for div in soup.find_all('div', class_='image-container overflow'): to avoid the backslash and the long line. Both are advised against in PEP8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bhaveshAn Please check why your PR is decreasing Code coverage?
Its because for every feature based PR, there is no test in |
Please resolve conflicts. |
Done @mariobehling |
Two PEP8 violations in this PR can be avoided with a simple one line change. The modifications to .travis.yml will also become unnecessary. |
@ParthS007 Now, I have also added tests respectively for Image/Video search in |
@cclauss Added tests at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ! Please squash the commits 👍
@ParthS007 Please approve the pull request |
My comments on --max-line-length=100 stand but perhaps others disagree with me. |
@ParthS007 @vaibhavsingh97 @mariobehling Please review |
Fixes #455
Addresses #320 and #321
Checklist
master
branch.Changes proposed in this pull request:
Travis CI build : https://travis-ci.org/bhaveshAn/query-server/builds/331264414
Providing heroku deployment at https://hidden-forest-11970.herokuapp.com/
@mariobehling @vaibhavsingh97 @ParthS007 Please review. Thanks !!