forked from ask/python-github2
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathusers.py
More file actions
52 lines (40 loc) · 1.99 KB
/
users.py
File metadata and controls
52 lines (40 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from github2.core import BaseData, GithubCommand, Attribute, DateAttribute
class User(BaseData):
id = Attribute("The user id")
login = Attribute("The login username")
name = Attribute("The users full name")
company = Attribute("Name of the company the user is associated with")
location = Attribute("Location of the user")
email = Attribute("The users e-mail address")
blog = Attribute("The users blog")
following_count = Attribute("Number of other users the user is following")
followers_count = Attribute("Number of users following this user")
public_gist_count = Attribute(
"Number of active public gists owned by the user")
public_repo_count = Attribute(
"Number of active repositories owned by the user")
total_private_repo_count = Attribute("Number of private repositories")
collaborators = Attribute("Number of collaborators")
disk_usage = Attribute("Currently used disk space")
owned_private_repo_count = Attribute("Number of privately owned repos")
private_gist_count = Attribute(
"Number of private gists owned by the user")
plan = Attribute("Current active github plan")
def is_authenticated(self):
return self.plan is not None
def __repr__(self):
return "<User: %s>" % (self.login)
class Users(GithubCommand):
domain = "user"
def search(self, query):
return self.get_values("search", query, filter="users", datatype=User)
def show(self, username):
return self.get_value("show", username, filter="user", datatype=User)
def followers(self, username):
return self.make_request("show", username, "followers", filter="users")
def following(self, username):
return self.make_request("show", username, "following", filter="users")
def follow(self, other_user):
return self.make_request("follow", other_user)
def unfollow(self, other_user):
return self.make_request("unfollow", other_user)