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

Add gathering data from github #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dvmazur
Copy link

@dvmazur dvmazur commented Dec 5, 2017

No description provided.

Copy link
Owner

@come-maiz come-maiz left a 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
Copy link
Owner

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.

@@ -0,0 +1 @@
from github.snapcraft import *
Copy link
Owner

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.

@@ -1,37 +1,122 @@
#!/usr/bin/env python2
#!/usr/bin/python2
Copy link
Owner

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.

def _get_snapcraft_yaml_file(github_repo):
def get_snapcraft_yaml_file(github_repo_url):
"""
Extracts snapcraft file from reposutory
Copy link
Owner

Choose a reason for hiding this comment

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

typo: repository

"""
Extracts snapcraft file from reposutory
:param github_repo_url: string, url of the repository
:return:
Copy link
Owner

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..

count[plugin] = 1
snapcraft_yaml_file.close()
return count
_scriplets = ["prepare", "build", "install", "version-script"]
Copy link
Owner

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.



cache_dir = os.path.join(
Copy link
Owner

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?

def _get_source_type_from_uri(source):
"""
Detect source type of source
Shamelesly stolen from https://github.com/snapcore/snapcraft/tree/master/snapcraft
Copy link
Owner

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):
Copy link
Owner

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
Copy link
Owner

Choose a reason for hiding this comment

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

typo: dictianories/dictionaries

@dvmazur
Copy link
Author

dvmazur commented Dec 5, 2017

Understood, will fix it.

@dvmazur dvmazur force-pushed the master branch 2 times, most recently from 62cd755 to 249dc4b Compare December 5, 2017 20:01
@dvmazur
Copy link
Author

dvmazur commented Dec 5, 2017

Updated code, squashed commits, waiting for your review :)

@@ -1,37 +1,126 @@
#!/usr/bin/env python2
#!/usr/bin/env/python2
Copy link
Owner

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.

Copy link
Owner

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.

import urlparse
import re
Copy link
Owner

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

count[plugin] = 1
snapcraft_yaml_file.close()
return count
_SCRIPLETS = ["prepare", "build", "install", "version-script"]
Copy link
Owner

@come-maiz come-maiz Dec 6, 2017

Choose a reason for hiding this comment

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

Please replace the " with '.

Copy link
Owner

@come-maiz come-maiz left a 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!

return urllib2.urlopen(url)
except:
pass
response = requests.request("GET", url)
Copy link
Owner

Choose a reason for hiding this comment

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

Please replace the " with '.


if response.status_code == 200:
return response.text

Copy link
Owner

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.

if response.status_code == 200:
return response.text

def get_plugins_count(snapcraft_file, plugins=None):
Copy link
Owner

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

Copy link
Owner

Choose a reason for hiding this comment

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

two empty lines between.

plugins[plugin] = 1
return plugins

def get_scriplets_count(snapcraft_file, scriplets=None):
Copy link
Owner

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

Copy link
Owner

Choose a reason for hiding this comment

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

two empty lines.

scriplets[line] += 1
return scriplets

def get_sources_count(snapcraft_file, sources=None):
Copy link
Owner

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

Copy link
Owner

Choose a reason for hiding this comment

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

two empty lines

@dvmazur
Copy link
Author

dvmazur commented Dec 6, 2017

updated, squashed

@dvmazur
Copy link
Author

dvmazur commented Dec 6, 2017

Forgot to fix some stuff, now done

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.

None yet

2 participants