diff options
author | Gauvain Pocentek <gauvain.pocentek@objectif-libre.com> | 2016-01-23 17:25:06 +0100 |
---|---|---|
committer | Gauvain Pocentek <gauvain.pocentek@objectif-libre.com> | 2016-01-23 17:25:30 +0100 |
commit | 2eac07139eb288cda2dd2d22d191ab3fc1053437 (patch) | |
tree | 8704db4cc3531b8c29488748ca4086b9d3dd892d | |
parent | d3a5701e5d481da452185e7a07d7b53493ed9073 (diff) | |
download | gitlab-2eac07139eb288cda2dd2d22d191ab3fc1053437.tar.gz |
add a decode method for ProjectFile
-rw-r--r-- | gitlab/objects.py | 9 | ||||
-rw-r--r-- | tools/python_test.py | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/gitlab/objects.py b/gitlab/objects.py index 95e1e45..6e15c3a 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -18,6 +18,7 @@ from __future__ import print_function from __future__ import division from __future__ import absolute_import +import base64 import copy import itertools import json @@ -922,6 +923,14 @@ class ProjectFile(GitlabObject): shortPrintAttr = 'file_path' getRequiresId = False + def decode(self): + """Returns the decoded content. + + Returns: + (str): the decoded content. + """ + return base64.b64decode(self.content) + class ProjectFileManager(BaseManager): obj_cls = ProjectFile diff --git a/tools/python_test.py b/tools/python_test.py index b646116..b1ad953 100644 --- a/tools/python_test.py +++ b/tools/python_test.py @@ -110,6 +110,7 @@ readme = admin_project.files.create({'file_path': 'README.rst', 'branch_name': 'master', 'content': 'Initial content', 'commit_message': 'New commit'}) +assert(readme.decode() == 'Initial content') # labels label1 = admin_project.labels.create({'name': 'label1', 'color': '#778899'}) |