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
Add gathering data from github #1
base: master
Are you sure you want to change the base?
Conversation
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.
Nice work! Thanks a lot.
I would like to keep in this repo only individual scripts, to leave people to get them and combine them to do their own stuff. So please remove the main, and leave it only on your repo. Also the init changes that you did to simplify the imports. Nothing wrong with them, just a personal preference of what to keep in this repo.
There is one thing I don't like about this. You are passing a dict that gets updated. That's called an output parameter, and sometimes it could be useful, but in general it should be avoided. The code is clearer, and simpler, if you just have one return value, and the caller takes care of using that value to update a variable, or something else.
Thank you!
README.md
Outdated
### Requirements: | ||
* Python 2.7 | ||
* Urlparse | ||
* Requests |
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 is just a collection of scripts that will be copied somewhere else. This README is great for your snapgatherer project, but it's not very useful here. What would be great here is to include the requirements on the header of each .py file. Nice job with this.
github/__init__.py
Outdated
@@ -0,0 +1 @@ | |||
from github.snapcraft import * |
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 remove this from this pull request. Again, it's great for the tool you made from the scripts, not for this repo with just a bunch of scripts.
github/snapcraft.py
Outdated
@@ -1,37 +1,122 @@ | |||
#!/usr/bin/env python2 | |||
#!/usr/bin/python2 |
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 revert this change. /usr/bin/env will support a python2 interpreter not installed in /usr/bin, like it happens with snaps.
github/snapcraft.py
Outdated
def _get_snapcraft_yaml_file(github_repo): | ||
def get_snapcraft_yaml_file(github_repo_url): | ||
""" | ||
Extracts snapcraft file from reposutory |
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.
typo: repository
github/snapcraft.py
Outdated
""" | ||
Extracts snapcraft file from reposutory | ||
:param github_repo_url: string, url of the repository | ||
:return: |
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.
Thanks for adding the comments. But you left that return incomplete, please document also the value returned..
github/snapcraft.py
Outdated
count[plugin] = 1 | ||
snapcraft_yaml_file.close() | ||
return count | ||
_scriplets = ["prepare", "build", "install", "version-script"] |
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 is a constant, so it should be _SCRIPTLETS.
For consistency, please use only single quotes for strings, instead of double quotes.
launchpad/snaps.py
Outdated
|
||
|
||
cache_dir = os.path.join( |
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 did you remove the cache dir here?
github/snapcraft.py
Outdated
def _get_source_type_from_uri(source): | ||
""" | ||
Detect source type of source | ||
Shamelesly stolen from https://github.com/snapcore/snapcraft/tree/master/snapcraft |
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.
It's not stealing, it's called free software :D
These scripts have a gpl license, which is the same that snapcraft uses. So it would be nice to have a better comment here.
Something like: Code copied from the snapcraft project: https://github.com/snapcore/snapcraft
main.py
Outdated
scriplets = dict() | ||
sources = dict() | ||
|
||
def updates_dicts(sfile): |
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.
sfile should be snapcraft_file, for clarity.
main.py
Outdated
|
||
def updates_dicts(sfile): | ||
""" | ||
Updates your snapfile dictianories |
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.
typo: dictianories/dictionaries
Understood, will fix it. |
62cd755
to
249dc4b
Compare
Updated code, squashed commits, waiting for your review :) |
github/snapcraft.py
Outdated
@@ -1,37 +1,126 @@ | |||
#!/usr/bin/env python2 | |||
#!/usr/bin/env/python2 |
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 is a bogus change. You shouldn't modify it, so please change the / back to a space.
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, wait, actually this python files has no main, so this shebang is not doing anything here.
You can just remove the line.
github/snapcraft.py
Outdated
import urlparse | ||
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.
It's common to sort the python imports alphabetically, grouping them by type: first python libs, then external libs, then libs local to the project. So, this should be:
import re
import urlparse
import requests
github/snapcraft.py
Outdated
count[plugin] = 1 | ||
snapcraft_yaml_file.close() | ||
return count | ||
_SCRIPLETS = ["prepare", "build", "install", "version-script"] |
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 replace the "
with '
.
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've left a few minor comments, mostly about style because I value consistency and clarity above all. But this is very good, I will approve your code-in task while you make the minor changes. Thanks!
github/snapcraft.py
Outdated
return urllib2.urlopen(url) | ||
except: | ||
pass | ||
response = requests.request("GET", url) |
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 replace the "
with '
.
github/snapcraft.py
Outdated
|
||
if response.status_code == 200: | ||
return response.text | ||
|
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.
The spacing should be consistent. Top-level functions should be separated by two empty lines.
github/snapcraft.py
Outdated
if response.status_code == 200: | ||
return response.text | ||
|
||
def get_plugins_count(snapcraft_file, plugins=None): |
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 remove this plugins output argument.
else: | ||
plugins[plugin] = 1 | ||
return plugins | ||
|
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.
two empty lines between.
github/snapcraft.py
Outdated
plugins[plugin] = 1 | ||
return plugins | ||
|
||
def get_scriplets_count(snapcraft_file, scriplets=None): |
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 remove this scriptlets output argument.
else: | ||
scriplets[line] += 1 | ||
return scriplets | ||
|
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.
two empty lines.
github/snapcraft.py
Outdated
scriplets[line] += 1 | ||
return scriplets | ||
|
||
def get_sources_count(snapcraft_file, sources=None): |
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 remove this sources output argument.
else: | ||
sources[src_type] = 1 | ||
return sources | ||
|
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.
two empty lines
updated, squashed |
Forgot to fix some stuff, now done |
No description provided.