mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 11:21:16 +00:00
Accept strings as well as Label objects (#202)
This should be more generic, but it's a wig work to do it everywhere. Let's keep that in mind for V2.
This commit is contained in:
+3
-6
@@ -16,13 +16,10 @@ Thank you, dear stargazers!
|
||||
|
||||
Starting today (September 5th, 2013), we now need more than 8 bits to store the number of `stargazers <https://github.com/jacquev6/PyGithub/stargazers>`_! Thank you so much!
|
||||
|
||||
`Version 1.20.0 <https://github.com/jacquev6/PyGithub/issues?milestone=32&state=closed>`_ (October 20th, 2013) (First Seattle edition)
|
||||
--------------------------------------------------------------------------------------------------------------------------------------
|
||||
`Version 1.21.0 <https://github.com/jacquev6/PyGithub/issues?milestone=33&state=closed>`_ (November ??th, 2013)
|
||||
---------------------------------------------------------------------------------------------------------------
|
||||
|
||||
* `Implement <https://github.com/jacquev6/PyGithub/issues/196>`_ ``Github.get_hook(name)``. Thank you `klmitch <https://github.com/klmitch>`_ for asking
|
||||
* In case bad data is returned by Github API v3, `raise <https://github.com/jacquev6/PyGithub/issues/195>`_ an exception only when the user accesses the faulty attribute, not when constructing the object containing this attribute. Thank you `klmitch <https://github.com/klmitch>`_ for asking
|
||||
* `Fix <https://github.com/jacquev6/PyGithub/issues/199>`_ parameter public/private of ``Repository.edit``. Thank you `daireobroin449 <https://github.com/daireobroin449>`_ for reporting the issue
|
||||
* Remove ``Repository.create_download`` and ``NamedUser.create_gist`` as the corrensponding APIs are not documented anymore
|
||||
* `Accept <https://github.com/jacquev6/PyGithub/issues/202>`__ strings as well as ``Label`` objects in ``Issue.add_to_labels``, ``Issue.remove_from_labels`` and ``Issue.set_labels``. Thank you `acdha <https://github.com/acdha>`__ for asking
|
||||
|
||||
Twitter
|
||||
-------
|
||||
|
||||
+10
-8
@@ -219,11 +219,11 @@ class Issue(github.GithubObject.CompletableGithubObject):
|
||||
def add_to_labels(self, *labels):
|
||||
"""
|
||||
:calls: `POST /repos/:owner/:repo/issues/:number/labels <http://developer.github.com/v3/issues/labels>`_
|
||||
:param label: :class:`github.Label.Label`
|
||||
:param label: :class:`github.Label.Label` or string
|
||||
:rtype: None
|
||||
"""
|
||||
assert all(isinstance(element, github.Label.Label) for element in labels), labels
|
||||
post_parameters = [label.name for label in labels]
|
||||
assert all(isinstance(element, (github.Label.Label, str, unicode)) for element in labels), labels
|
||||
post_parameters = [label.name if isinstance(label, github.Label.Label) else label for label in labels]
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/labels",
|
||||
@@ -346,13 +346,15 @@ class Issue(github.GithubObject.CompletableGithubObject):
|
||||
def remove_from_labels(self, label):
|
||||
"""
|
||||
:calls: `DELETE /repos/:owner/:repo/issues/:number/labels/:name <http://developer.github.com/v3/issues/labels>`_
|
||||
:param label: :class:`github.Label.Label`
|
||||
:param label: :class:`github.Label.Label` or string
|
||||
:rtype: None
|
||||
"""
|
||||
assert isinstance(label, github.Label.Label), label
|
||||
assert isinstance(label, (github.Label.Label, str, unicode)), label
|
||||
if isinstance(label, github.Label.Label):
|
||||
label = label._identity
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url + "/labels/" + label._identity
|
||||
self.url + "/labels/" + label
|
||||
)
|
||||
|
||||
def set_labels(self, *labels):
|
||||
@@ -361,8 +363,8 @@ class Issue(github.GithubObject.CompletableGithubObject):
|
||||
:param label: :class:`github.Label.Label`
|
||||
:rtype: None
|
||||
"""
|
||||
assert all(isinstance(element, github.Label.Label) for element in labels), labels
|
||||
post_parameters = [label.name for label in labels]
|
||||
assert all(isinstance(element, (github.Label.Label, str, unicode)) for element in labels), labels
|
||||
post_parameters = [label.name if isinstance(label, github.Label.Label) else label for label in labels]
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PUT",
|
||||
self.url + "/labels",
|
||||
|
||||
@@ -104,6 +104,17 @@ class Issue(Framework.TestCase):
|
||||
self.issue.add_to_labels(bug, question)
|
||||
self.assertListKeyEqual(self.issue.get_labels(), lambda l: l.name, ["Bug", "Project management", "Question"])
|
||||
|
||||
def testAddAndRemoveLabelsWithStringArguments(self):
|
||||
bug = "Bug"
|
||||
question = "Question"
|
||||
self.assertListKeyEqual(self.issue.get_labels(), lambda l: l.name, ["Bug", "Project management", "Question"])
|
||||
self.issue.remove_from_labels(bug)
|
||||
self.assertListKeyEqual(self.issue.get_labels(), lambda l: l.name, ["Project management", "Question"])
|
||||
self.issue.remove_from_labels(question)
|
||||
self.assertListKeyEqual(self.issue.get_labels(), lambda l: l.name, ["Project management"])
|
||||
self.issue.add_to_labels(bug, question)
|
||||
self.assertListKeyEqual(self.issue.get_labels(), lambda l: l.name, ["Bug", "Project management", "Question"])
|
||||
|
||||
def testDeleteAndSetLabels(self):
|
||||
bug = self.repo.get_label("Bug")
|
||||
question = self.repo.get_label("Question")
|
||||
@@ -112,3 +123,12 @@ class Issue(Framework.TestCase):
|
||||
self.assertListKeyEqual(self.issue.get_labels(), None, [])
|
||||
self.issue.set_labels(bug, question)
|
||||
self.assertListKeyEqual(self.issue.get_labels(), lambda l: l.name, ["Bug", "Question"])
|
||||
|
||||
def testDeleteAndSetLabelsWithStringArguments(self):
|
||||
bug = "Bug"
|
||||
question = "Question"
|
||||
self.assertListKeyEqual(self.issue.get_labels(), lambda l: l.name, ["Bug", "Project management", "Question"])
|
||||
self.issue.delete_labels()
|
||||
self.assertListKeyEqual(self.issue.get_labels(), None, [])
|
||||
self.issue.set_labels(bug, question)
|
||||
self.assertListKeyEqual(self.issue.get_labels(), lambda l: l.name, ["Bug", "Question"])
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/repos/jacquev6/PyGithub/issues/28/labels
|
||||
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
null
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4990'), ('content-length', '335'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"c9f9beccb03030beaf7b80927da6fef6"'), ('date', 'Sun, 27 May 2012 09:04:03 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Bug","name":"Bug","color":"e10c02"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Project+management","name":"Project management","color":"444444"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Question","name":"Question","color":"02e10c"}]
|
||||
|
||||
https
|
||||
DELETE
|
||||
api.github.com
|
||||
None
|
||||
/repos/jacquev6/PyGithub/issues/28/labels/Bug
|
||||
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
null
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4989'), ('content-length', '237'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"46cc70bad88a09b559a5e67089005105"'), ('date', 'Sun, 27 May 2012 09:04:03 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Project+management","name":"Project management","color":"444444"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Question","name":"Question","color":"02e10c"}]
|
||||
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/repos/jacquev6/PyGithub/issues/28/labels
|
||||
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
null
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4988'), ('content-length', '237'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"46cc70bad88a09b559a5e67089005105"'), ('date', 'Sun, 27 May 2012 09:04:04 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Project+management","name":"Project management","color":"444444"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Question","name":"Question","color":"02e10c"}]
|
||||
|
||||
https
|
||||
DELETE
|
||||
api.github.com
|
||||
None
|
||||
/repos/jacquev6/PyGithub/issues/28/labels/Question
|
||||
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
null
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4987'), ('content-length', '129'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"5352ae15c8a5a36c6cace63be9367332"'), ('date', 'Sun, 27 May 2012 09:04:04 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Project+management","name":"Project management","color":"444444"}]
|
||||
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/repos/jacquev6/PyGithub/issues/28/labels
|
||||
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
null
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4986'), ('content-length', '129'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"5352ae15c8a5a36c6cace63be9367332"'), ('date', 'Sun, 27 May 2012 09:04:05 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Project+management","name":"Project management","color":"444444"}]
|
||||
|
||||
https
|
||||
POST
|
||||
api.github.com
|
||||
None
|
||||
/repos/jacquev6/PyGithub/issues/28/labels
|
||||
{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
["Bug", "Question"]
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4985'), ('content-length', '335'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d135d74d2ea2159d044676a220d41d3a"'), ('date', 'Sun, 27 May 2012 09:04:06 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
[{"color":"e10c02","url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Bug","name":"Bug"},{"color":"444444","url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Project+management","name":"Project management"},{"color":"02e10c","url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Question","name":"Question"}]
|
||||
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/repos/jacquev6/PyGithub/issues/28/labels
|
||||
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
null
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4984'), ('content-length', '335'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"c9f9beccb03030beaf7b80927da6fef6"'), ('date', 'Sun, 27 May 2012 09:04:06 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Bug","name":"Bug","color":"e10c02"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Project+management","name":"Project management","color":"444444"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Question","name":"Question","color":"02e10c"}]
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/repos/jacquev6/PyGithub/issues/28/labels
|
||||
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
null
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4972'), ('content-length', '335'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d135d74d2ea2159d044676a220d41d3a"'), ('date', 'Sun, 27 May 2012 09:06:39 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
[{"color":"e10c02","url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Bug","name":"Bug"},{"color":"444444","url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Project+management","name":"Project management"},{"color":"02e10c","url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Question","name":"Question"}]
|
||||
|
||||
https
|
||||
DELETE
|
||||
api.github.com
|
||||
None
|
||||
/repos/jacquev6/PyGithub/issues/28/labels
|
||||
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
null
|
||||
204
|
||||
[('status', '204 No Content'), ('x-ratelimit-remaining', '4971'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d41d8cd98f00b204e9800998ecf8427e"'), ('date', 'Sun, 27 May 2012 09:06:39 GMT')]
|
||||
|
||||
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/repos/jacquev6/PyGithub/issues/28/labels
|
||||
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
null
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4970'), ('content-length', '2'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d751713988987e9331980363e24189ce"'), ('date', 'Sun, 27 May 2012 09:06:40 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
[]
|
||||
|
||||
https
|
||||
PUT
|
||||
api.github.com
|
||||
None
|
||||
/repos/jacquev6/PyGithub/issues/28/labels
|
||||
{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
["Bug", "Question"]
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4969'), ('content-length', '207'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"1a56634d9c1050a88592ff55ed8adc62"'), ('date', 'Sun, 27 May 2012 09:06:40 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Bug","name":"Bug","color":"e10c02"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Question","name":"Question","color":"02e10c"}]
|
||||
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/repos/jacquev6/PyGithub/issues/28/labels
|
||||
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
null
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4968'), ('content-length', '207'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"1a56634d9c1050a88592ff55ed8adc62"'), ('date', 'Sun, 27 May 2012 09:06:41 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Bug","name":"Bug","color":"e10c02"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Question","name":"Question","color":"02e10c"}]
|
||||
|
||||
Reference in New Issue
Block a user