Skip to content
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

Added option to open stack overflow url directly, closes #191 #193

Merged
merged 8 commits into from
Jul 8, 2020
Merged

Added option to open stack overflow url directly, closes #191 #193

merged 8 commits into from
Jul 8, 2020

Conversation

pspiagicw
Copy link
Contributor

The Pull Request adds support for opening stackoverflow urls through socli.This was my first pull request so I worked on something that was easy.
If url is not eligible to open in socli , it opens in the browser . If url points to tag it opens the corresponding tag in socli.
If it is a normal question url it opens within socli.
To be just sure I also mentioned this in the Issues section.

@hedyhli hedyhli changed the title Added option to open stack overflow url directly , as refered in issue #191 Added option to open stack overflow url directly, closes #191 Jul 6, 2020
@hedyhli hedyhli linked an issue Jul 6, 2020 that may be closed by this pull request
@hedyhli
Copy link
Collaborator

hedyhli commented Jul 6, 2020

Thank you for your first PR, I will review it shortly.

CC @gautamkrishnar

Copy link
Owner

@gautamkrishnar gautamkrishnar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add some tests for this new argument? Please add it to socli/tests

@pspiagicw
Copy link
Contributor Author

Okay will add as soon as possible.

@gautamkrishnar
Copy link
Owner

@prathampowar2001 please take your time.

socli/socli.py Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
socli/parser.py Outdated Show resolved Hide resolved
@hedyhli
Copy link
Collaborator

hedyhli commented Jul 7, 2020

Oh and I think --open-url instead of --open_url will be better for command line options

Edit: resolved in commit after

socli/tests/test_socli.py Outdated Show resolved Hide resolved
socli/socli.py Outdated Show resolved Hide resolved
Copy link
Owner

@gautamkrishnar gautamkrishnar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests LGTM 👍

socli/tests/test_socli.py Outdated Show resolved Hide resolved
@hedyhli
Copy link
Collaborator

hedyhli commented Jul 7, 2020

@prathampowar2001 The travis tests are failing due to using namespace.open-url please update accordingly as to the comments above open_url, everything else seems ok. Please also make sure you test your functionalities (--open-url with valid/invalid URLs)

@pspiagicw
Copy link
Contributor Author

I tested manually the functionality --open-url or -o with multiple urls
This is my analysis
Stack Overflow url's that are viewable in socli are of three types

  1. https://stackoverflow.com/questions/tagged/**tag**
    This is handled by extracting the tag using regular expression and opening the corresponding tag in socli.

  2. https://stackoverflow.com/questions/**id and question**
    This is handled by opening the url directly in socli.

  3. https://stackoverrflow.com/tags/**tag**
    This is handled by extracting the tag and opening it in socli.

4.https://stackoverflow.blog/****
This is handled by warning the user and opening the browser.

If a url does not contain https:// , eg. stackoverflow.com , It adds https:// to the start of it.

If it is not a stackoverflow url it warns the user and opens in a browser.

For a invalid url it check's it with a request module and if invalid then warns the user and exits

I have manually tested with atleast 10-15 url's

All the above is included in the next commit

Copy link
Collaborator

@hedyhli hedyhli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 👍 I will test it again tomorrow if gautamkrishnar doesn't merge this today

@hedyhli
Copy link
Collaborator

hedyhli commented Jul 7, 2020

Oh! Looks like it's failing codacy, you could just do a request.get without assigning it to a variable to resolve one of the unused variable issues. And then there seems to be trailing whitespaces on an if statement:

https://app.codacy.com/manual/gautamkrishnar/socli/pullRequest?prid=5814058

@pspiagicw
Copy link
Contributor Author

It looks like all done and dusted . Thank you for the pain and effort you all took to correct my silly or sometimes irritating mistakes . And definately it was a learning experience for me as I contributed to a real open source project for the first time and learnt multiple things that would help me in the future . As a python and github newbie it was a very good experience .

Copy link
Collaborator

@hedyhli hedyhli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks better now 👍🏼 Even though the raising connection error might confuse someone reading it but I do not think that matters and can be fixed later, thank you for your effort 😃

Will probably be merged after @gautamkrishnar checks it again

@gautamkrishnar
Copy link
Owner

gautamkrishnar commented Jul 8, 2020

@hedythedev @prashantchahal26 just updated the code and moved the requests.get after the if check for the correct URL so that users don't have to trigger an api call if the check fails.

Copy link
Owner

Codacy Here is an overview of what got changed by this pull request:

Complexity increasing per file
==============================
- socli/socli.py  11
         

Clones added
============
- socli/tests/test_socli.py  5
         

See the complete overview on Codacy

Repository owner deleted a comment from hedyhli Jul 8, 2020
@gautamkrishnar
Copy link
Owner

@hedythedev really sorry for deleting your comment that was an accident.

@gautamkrishnar
Copy link
Owner

@all-contributors please add @prathampowar2001 for code

@allcontributors
Copy link
Contributor

@gautamkrishnar

I've put up a pull request to add @prathampowar2001! 🎉

@gautamkrishnar gautamkrishnar merged commit d0e43c4 into gautamkrishnar:master Jul 8, 2020
@gautamkrishnar
Copy link
Owner

@prathampowar2001 thanks a lot for the contribution. You rocks ⭐

gautamkrishnar added a commit that referenced this pull request Sep 7, 2020
* Added option to open stack overflow url directly , as refered in issue#191

* Added tests , Made some bug fixes , Made all discussed changes

* Changed open_url to open-url

* Changed multiple things, added support for invalid url and passing all checks on my side

* Codacy checks passing

* Optimised and refactored code

* use generic Exception

* Improve messages printed to the user

Co-authored-by: Gautam krishna R <rgautamkrishna@gmail.com>
Co-authored-by: Hedy Li <hedyhyry@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Option to load stack overflow url directly
3 participants