Skip to content

Commit 2eac071

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

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy