Skip to content

Commit 064e2b4

Browse files
author
Gauvain Pocentek
committed
Snippet: content() -> raw()
Using the content() method causes conflicts with the API `content` attribute.
1 parent 7453895 commit 064e2b4

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

docs/gl_objects/snippets.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# get
1010
snippet = gl.snippets.get(snippet_id)
1111
# get the content
12-
content = snippet.content()
12+
content = snippet.raw()
1313
# end get
1414

1515
# create
@@ -19,7 +19,7 @@
1919
# end create
2020

2121
# update
22-
snippet.visibility_level = gitlab.VISIBILITY_PUBLIC
22+
snippet.visibility_level = gitlab.Project.VISIBILITY_PUBLIC
2323
snippet.save()
2424
# end update
2525

gitlab/objects.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ class Snippet(GitlabObject):
10261026
optionalUpdateAttrs = ['title', 'file_name', 'content', 'visibility_level']
10271027
shortPrintAttr = 'title'
10281028

1029-
def content(self, streamed=False, action=None, chunk_size=1024, **kwargs):
1029+
def raw(self, streamed=False, action=None, chunk_size=1024, **kwargs):
10301030
"""Return the raw content of a snippet.
10311031
10321032
Args:
@@ -1038,14 +1038,13 @@ def content(self, streamed=False, action=None, chunk_size=1024, **kwargs):
10381038
chunk_size (int): Size of each chunk.
10391039
10401040
Returns:
1041-
str: The snippet content
1041+
str: The snippet content.
10421042
10431043
Raises:
10441044
GitlabConnectionError: If the server cannot be reached.
10451045
GitlabGetError: If the server fails to perform the request.
10461046
"""
1047-
url = ("/snippets/%(snippet_id)s/raw" %
1048-
{'snippet_id': self.id})
1047+
url = ("/snippets/%(snippet_id)s/raw" % {'snippet_id': self.id})
10491048
r = self.gitlab._raw_get(url, **kwargs)
10501049
raise_error_from_response(r, GitlabGetError)
10511050
return utils.response_content(r, streamed, action, chunk_size)

gitlab/tests/test_gitlabobject.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,9 @@ def resp_content_fail(self, url, request):
483483
def test_content(self):
484484
with HTTMock(self.resp_content):
485485
data = b'content'
486-
content = self.obj.content()
486+
content = self.obj.raw()
487487
self.assertEqual(content, data)
488488

489489
def test_blob_fail(self):
490490
with HTTMock(self.resp_content_fail):
491-
self.assertRaises(GitlabGetError, self.obj.content)
491+
self.assertRaises(GitlabGetError, self.obj.raw)

0 commit comments

Comments
 (0)