Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0749609

Browse files
committed
Start adding __str__ methods where logical
For example, if you want to dou = github3.user(username)r = github3.repository(u, reponame)This should work now work. I'm looking for other areas to add thisfunctionality.
1 parent6228999 commit0749609

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

‎github3/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ def _build_url(self, *args, **kwargs):
133133
"""Builds a new API url from scratch."""
134134
parts= [kwargs.get('base_url')orself._github_url]
135135
parts.extend(args)
136+
parts= [str(p)forpinparts]
136137
key=tuple(parts)
137138
ifnotkeyin__url_cache__:
138139
__url_cache__[key]='/'.join(parts)

‎github3/repos.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ def __init__(self, repo, session=None):
111111
self.master_branch=repo.get('master_branch','')
112112

113113
def__repr__(self):
114-
return'<Repository [{0}/{1}]>'.format(self.owner.login,self.name)
114+
return'<Repository [{0}]>'.format(self)
115+
116+
def__str__(self):
117+
return'{0}/{1}'.format(self.owner,self.name)
115118

116119
def_update_(self,repo):
117120
self.__init__(repo,self._session)
@@ -1350,6 +1353,9 @@ def __init__(self, content):
13501353
def__repr__(self):
13511354
return'<Content [{0}]>'.format(self.path)
13521355

1356+
def__str__(self):
1357+
returnself.decoded
1358+
13531359
@property
13541360
defgit_url(self):
13551361
"""API URL for this blob"""
@@ -1535,7 +1541,10 @@ def __init__(self, tag):
15351541
self.commit=tag.get('commit', {})
15361542

15371543
def__repr__(self):
1538-
return'<Repository Tag [{0}]>'.format(self.name)
1544+
return'<Repository Tag [{0}]>'.format(self)
1545+
1546+
def__str__(self):
1547+
returnself.name
15391548

15401549

15411550
classRepoComment(BaseComment):

‎github3/users.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ def __init__(self, key, session=None):
2626
def__repr__(self):
2727
return'<User Key [{0}]>'.format(self.title)
2828

29+
def__str__(self):
30+
returnself.key
31+
2932
def_update_(self,key):
3033
self.__init__(key,self._session)
3134

@@ -70,6 +73,9 @@ def __init__(self, plan):
7073
def__repr__(self):
7174
return'<Plan [{0}]>'.format(self.name)# (No coverage)
7275

76+
def__str__(self):
77+
returnself.name
78+
7379
defis_free(self):
7480
"""Checks if this is a free plan.
7581
@@ -131,6 +137,9 @@ def __init__(self, user, session=None):
131137
def__repr__(self):
132138
return'<User [{0}:{1}]>'.format(self.login,self.name)
133139

140+
def__str__(self):
141+
returnself.login
142+
134143
def_update_(self,user):
135144
self.__init__(user,self._session)
136145

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp