-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathblob.py
34 lines (27 loc) · 772 Bytes
/
blob.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from dataclasses import dataclass
@dataclass(slots=True)
class Blob:
""" Class that defines Blob objects for GitLab blobs"""
basename: str
data: str
path: str
filename: str
id: str
ref: str
project_id: str
def create_from_dict(blob_dict: dict) -> Blob:
""" Create a Blob object from a dict response from the GitLab API
Args:
blob_dict: dict/JSON format data from GitLab API
Returns:
A new Blob object
"""
return Blob(
id=blob_dict.get('id'),
basename=blob_dict.get('basename'),
data=blob_dict.get('data'),
path=blob_dict.get('path'),
filename=blob_dict.get('filename'),
ref=blob_dict.get('ref'),
project_id=blob_dict.get('project_id')
)