FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

add a decode method for ProjectFile · python-gitlab/python-gitlab@2eac071 · GitHub

Repository navigation

Commit 2eac071

Browse files
Gauvain Pocentek
committed
add a decode method for ProjectFile
1 parent d3a5701 commit 2eac071

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

‎gitlab/objects.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from __future__ import print_function
1919
from __future__ import division
2020
from __future__ import absolute_import
21+
import base64
2122
import copy
2223
import itertools
2324
import json
@@ -922,6 +923,14 @@ class ProjectFile(GitlabObject):
922923
shortPrintAttr = 'file_path'
923924
getRequiresId = False
924925

926+
def decode(self):
927+
"""Returns the decoded content.
928+
929+
Returns:
930+
(str): the decoded content.
931+
"""
932+
return base64.b64decode(self.content)
933+
925934

926935
class ProjectFileManager(BaseManager):
927936
obj_cls = ProjectFile

‎tools/python_test.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
'branch_name': 'master',
111111
'content': 'Initial content',
112112
'commit_message': 'New commit'})
113+
assert(readme.decode() == 'Initial content')
113114

114115
# labels
115116
label1 = admin_project.labels.create({'name': 'label1', 'color': '#778899'})

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL