Module aiogithubapi.objects.repository.content
AIOGitHubAPI: Repository Content
https://developer.github.com/v3/repos/contents/
Expand source code
"""
AIOGitHubAPI: Repository Content
https://developer.github.com/v3/repos/contents/
"""
# pylint: disable=missing-docstring
import base64
from ..content import AIOGitHubAPIContentBase
class AIOGitHubAPIRepositoryContent(AIOGitHubAPIContentBase):
"""Repository Conetent GitHub API implementation."""
@property
def type(self):
return self.attributes.get("type", "file")
@property
def encoding(self):
return self.attributes.get("encoding")
@property
def name(self):
return self.attributes.get("name")
@property
def path(self):
return self.attributes.get("path")
@property
def content(self):
return base64.b64decode(bytearray(self.attributes.get("content"), "utf-8")).decode()
@property
def download_url(self):
return self.attributes.get("download_url") or self.attributes.get("browser_download_url")
class AIOGitHubAPIRepositoryTreeContent(AIOGitHubAPIContentBase):
"""Repository Conetent GitHub API implementation."""
def __init__(self, attributes, repository, ref):
"""Initialize."""
self.attributes = attributes
self.repository = repository
self.ref = ref
@property
def full_path(self):
return self.attributes.get("path")
@property
def is_directory(self):
if self.attributes.get("type") == "tree":
return True
return False
@property
def path(self):
path = ""
if "/" in self.attributes.get("path"):
path = self.attributes.get("path").split(
f"/{self.attributes.get('path').split('/')[-1]}"
)[0]
return path
@property
def filename(self):
filename = self.attributes.get("path")
if "/" in self.attributes.get("path"):
filename = self.attributes.get("path").split("/")[-1]
return filename
@property
def url(self):
return self.attributes.get("url")
@property
def download_url(self):
return f"https://raw.githubusercontent.com/{self.repository}/{self.ref}/{self.attributes.get('path')}"
Classes
class AIOGitHubAPIRepositoryContent (attributes)
-
Repository Conetent GitHub API implementation.
Initialize.
Expand source code
class AIOGitHubAPIRepositoryContent(AIOGitHubAPIContentBase): """Repository Conetent GitHub API implementation.""" @property def type(self): return self.attributes.get("type", "file") @property def encoding(self): return self.attributes.get("encoding") @property def name(self): return self.attributes.get("name") @property def path(self): return self.attributes.get("path") @property def content(self): return base64.b64decode(bytearray(self.attributes.get("content"), "utf-8")).decode() @property def download_url(self): return self.attributes.get("download_url") or self.attributes.get("browser_download_url")
Ancestors
Instance variables
var content
-
Expand source code
@property def content(self): return base64.b64decode(bytearray(self.attributes.get("content"), "utf-8")).decode()
var download_url
-
Expand source code
@property def download_url(self): return self.attributes.get("download_url") or self.attributes.get("browser_download_url")
var encoding
-
Expand source code
@property def encoding(self): return self.attributes.get("encoding")
var name
-
Expand source code
@property def name(self): return self.attributes.get("name")
var path
-
Expand source code
@property def path(self): return self.attributes.get("path")
var type
-
Expand source code
@property def type(self): return self.attributes.get("type", "file")
class AIOGitHubAPIRepositoryTreeContent (attributes, repository, ref)
-
Repository Conetent GitHub API implementation.
Initialize.
Expand source code
class AIOGitHubAPIRepositoryTreeContent(AIOGitHubAPIContentBase): """Repository Conetent GitHub API implementation.""" def __init__(self, attributes, repository, ref): """Initialize.""" self.attributes = attributes self.repository = repository self.ref = ref @property def full_path(self): return self.attributes.get("path") @property def is_directory(self): if self.attributes.get("type") == "tree": return True return False @property def path(self): path = "" if "/" in self.attributes.get("path"): path = self.attributes.get("path").split( f"/{self.attributes.get('path').split('/')[-1]}" )[0] return path @property def filename(self): filename = self.attributes.get("path") if "/" in self.attributes.get("path"): filename = self.attributes.get("path").split("/")[-1] return filename @property def url(self): return self.attributes.get("url") @property def download_url(self): return f"https://raw.githubusercontent.com/{self.repository}/{self.ref}/{self.attributes.get('path')}"
Ancestors
Instance variables
var download_url
-
Expand source code
@property def download_url(self): return f"https://raw.githubusercontent.com/{self.repository}/{self.ref}/{self.attributes.get('path')}"
var filename
-
Expand source code
@property def filename(self): filename = self.attributes.get("path") if "/" in self.attributes.get("path"): filename = self.attributes.get("path").split("/")[-1] return filename
var full_path
-
Expand source code
@property def full_path(self): return self.attributes.get("path")
var is_directory
-
Expand source code
@property def is_directory(self): if self.attributes.get("type") == "tree": return True return False
var path
-
Expand source code
@property def path(self): path = "" if "/" in self.attributes.get("path"): path = self.attributes.get("path").split( f"/{self.attributes.get('path').split('/')[-1]}" )[0] return path
var url
-
Expand source code
@property def url(self): return self.attributes.get("url")