-
Notifications
You must be signed in to change notification settings - Fork 13
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
Refactored the project #19
Conversation
} | ||
|
||
# Method to fetch categories | ||
def get_categories(self, clshow="!hidden"): |
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.
One of the motivations of this project is so that the users need not bother themselves with the details of the API. Try to use generic names wherever possible. clshow
is very misleading who isn't familiar with the API.
@@ -0,0 +1,19 @@ | |||
import re |
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.
You need not create a separate file for helpers
. Better keep them in the same file as core.py
outside WikiPage
class and prefix them with _
. Names starting with _
are supposed to refer to functions that should not be messed with by the user unless the user is sure what they are doing. "We're all consenting adults here" 😉
|
||
img_list = helpers.beautiful(res, prop, 'File') | ||
while 'continue' in res: | ||
payload['imcontinue'] = res['continue']['imcontinue'] |
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.
I think this should be self.payload
.
return res['query']['pages'][pageids][prop] | ||
|
||
|
||
def beautiful(res, prop, strip_chars): |
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.
We need a better name for this 🤔
for pageid, page_content in res['query']['pages'].items(): | ||
if prop not in page_content: | ||
continue | ||
ret[pageid] = [strip_prop(content['title'], strip_chars) for content in page_content[prop]] |
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.
entry
seems like a better replacement for content
here.
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.
@ayuhsya I meant [strip_prop(entry['title'], strip_chars) for entry in page_content[prop]]
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.
Oh! 😐
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.
@abinashmeher999 I've changed the variable name.
@abinashmeher999 I've made the changes. I've deleted |
wk = WikiPage('843158','20715044') | ||
pprint(wk.get_categories()) | ||
#pprint(wk.get_images()) | ||
#pprint(wk.get_linkshere()) |
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 you uncomment these 2? I need to check the output once just to be sure.
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.
@abinashmeher999 Okay, done.
@abinashmeher999 Every time I'm asked to make a change, I follow these commands to push them:
I did rebase because you once asked me to squash all commits in one before making a PR. |
Squashing them is your choice. I asked them the last time because some of the commits had unclear names and some changes didn't need to have a commit of there own. In this case you could have kept separate commits. There's nothing like squashing all the commits in a PR is a good practice. I would advise that you fetch the upstream and rebase on top of the branch you are working on. |
Addresses #7 |
And of course the module name is not |
@abinashmeher999 It says in the guide that the main module should reside in the sample folder. |
@ayuhsya 😐 That's because the project name is 'sample' https://github.com/kennethreitz/samplemod/blob/master/setup.py |
😢 Damn, I thought that was the standard. |
😆 We all have been there. |
Created two new python scripts:
core.py
Contains the main WikiPage class with methods for each Wiki property.helpers.py
Contain methods to strip the JSON response.And deleted the scripts
wiki_cat.py, wiki_linkshere.py, wiki_images.py
whose methods have been added incore.py
script.