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

Commit064e2b4

Browse files
author
Gauvain Pocentek
committed
Snippet: content() -> raw()
Using the content() method causes conflicts with the API `content`attribute.
1 parent7453895 commit064e2b4

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

‎docs/gl_objects/snippets.py

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 4 deletions
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-
defcontent(self,streamed=False,action=None,chunk_size=1024,**kwargs):
1029+
defraw(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
returnutils.response_content(r,streamed,action,chunk_size)

‎gitlab/tests/test_gitlabobject.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,9 @@ def resp_content_fail(self, url, request):
483483
deftest_content(self):
484484
withHTTMock(self.resp_content):
485485
data=b'content'
486-
content=self.obj.content()
486+
content=self.obj.raw()
487487
self.assertEqual(content,data)
488488

489489
deftest_blob_fail(self):
490490
withHTTMock(self.resp_content_fail):
491-
self.assertRaises(GitlabGetError,self.obj.content)
491+
self.assertRaises(GitlabGetError,self.obj.raw)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp