# Path: mainhandler.py
# class Handler(webapp2.RequestHandler):
#     def write(self, *a, **kw):
#         self.response.out.write(*a, **kw)
# 
#     def render_str(self, template, **params):
#         t = jinja_env.get_template(template)
#         return t.render(params)
# 
#     def render(self, template, **kw):
#         self.write(self.render_str(template, **kw))
# 
#     def render_front(self, template):
#         self.render(template)
# 
# Path: app/utilities/utils.py
# def setUser(user="", password=""):
#     return Github(user, password).get_user()
# 
# def getFollowers(user):
#     followers = []
#     for f in user.get_followers():
#         ret = {}
#         ret['type'] = "Followers"
#         namedUser = Github().get_user(f.login)
#         if namedUser.name: 
#             ret['name'] = namedUser.name + " - (" + f.login + ")"
#         else:
#             ret['name'] = f.login
#         ret['url'] = "https://github.com/" + f.login
#         followers.append(ret)
#     return followers
# 
# def getFollowing(user):
#     following = []
#     for f in user.get_following():
#         ret = {}
#         ret['type'] = "Following"
#         namedUser = Github().get_user(f.login)
#         if namedUser.name: 
#             ret['name'] = namedUser.name + " - (" + f.login + ")"
#         else:
#             ret['name'] = f.login
#         ret['url'] = "https://github.com/" + f.login
#         following.append(ret)
#     return following
# 
# def getWatchedRepos(user):
#     watched = []
#     for w in user.get_watched():
#         ret = {}
#         ret['type'] = "Watched"
#         ret['name'] = w.name + " - " + w.description
#         ret['url'] = w.html_url
#         watched.append(ret)
#     return watched


import json
from mainhandler import Handler
from app.utilities.utils import setUser, getFollowers, getFollowing, getWatchedRepos 
'''
Created on Oct 1, 2012

@author: Sagar
'''

class GithubActivity(Handler):
    def get(self):
        activity = {}
        entries = []
        user = setUser("<username>", "<password>")
        entries = entries + getFollowers(user)

# Path: mainhandler.py
# class Handler(webapp2.RequestHandler):
#     def write(self, *a, **kw):
#         self.response.out.write(*a, **kw)
# 
#     def render_str(self, template, **params):
#         t = jinja_env.get_template(template)
#         return t.render(params)
# 
#     def render(self, template, **kw):
#         self.write(self.render_str(template, **kw))
# 
#     def render_front(self, template):
#         self.render(template)
# 
# Path: app/utilities/utils.py
# def setUser(user="", password=""):
#     return Github(user, password).get_user()
# 
# def getFollowers(user):
#     followers = []
#     for f in user.get_followers():
#         ret = {}
#         ret['type'] = "Followers"
#         namedUser = Github().get_user(f.login)
#         if namedUser.name: 
#             ret['name'] = namedUser.name + " - (" + f.login + ")"
#         else:
#             ret['name'] = f.login
#         ret['url'] = "https://github.com/" + f.login
#         followers.append(ret)
#     return followers
# 
# def getFollowing(user):
#     following = []
#     for f in user.get_following():
#         ret = {}
#         ret['type'] = "Following"
#         namedUser = Github().get_user(f.login)
#         if namedUser.name: 
#             ret['name'] = namedUser.name + " - (" + f.login + ")"
#         else:
#             ret['name'] = f.login
#         ret['url'] = "https://github.com/" + f.login
#         following.append(ret)
#     return following
# 
# def getWatchedRepos(user):
#     watched = []
#     for w in user.get_watched():
#         ret = {}
#         ret['type'] = "Watched"
#         ret['name'] = w.name + " - " + w.description
#         ret['url'] = w.html_url
#         watched.append(ret)
#     return watched


# Path: app/utilities/githubactivity.py
import json
from mainhandler import Handler
from app.utilities.utils import setUser, getFollowers, getFollowing, getWatchedRepos 

'''
Created on Oct 1, 2012

@author: Sagar
'''

class GithubActivity(Handler):
    def get(self):
        activity = {}
        entries = []
        user = setUser("<username>", "<password>")
        entries = entries + getFollowers(user)

        entries = entries + getFollowing(user)