import github3
import getpass

"""
Explanation: github3.py
github3.py is wrapper for the GitHub API written in python
pip install github3.py
End of explanation
"""


username = 'mjuenema'
password = getpass.getpass('Password for {0}: '.format(user))

login = github3.login(username, password)
user = login.user()

user.name, user.bio, user.email, user.type, user.created_at

"""
Explanation: Logging in
Logging into Github gives higher rates at which to perform Github API calls.
End of explanation
"""


search = login.search_repositories(query='a language:HCL modified>')
search

repositories = list(search)

len(repositories)

repository = repositories[10]
repository

repository.repository.full_name, repository.repository.size, repository.repository.clone_url, repository.repository.language

repository.repository.owner, repository.repository.owner.login, repository.repository.owner.repos_url

repository.repository.id, repository.repository.owner.html_url

repository.repository.description

search = login.search_repositories(query='aws in:name,description,readme language:HCL> pushed>2017-03-01')

repository = repositories[0]
repository

repository.repository.pushed_at

readme = repository.repository.contents('README.md')

readme.html_url

markdown = login.markdown(readme.decoded)

markdown[:100]

files = repository.repository.contents('/')

files

admin = files['admin']

admin.type

admin.name, admin.path

admin_files = repository.repository.contents(admin.path)

admin_files

"""
Explanation: Searching
Searching repositories
Searching repositories
End of explanation
"""


