kopia lustrzana https://github.com/Langenfeld/py-gitea
pull/12/head
rodzic
75f99a6451
commit
6db35aab26
|
@ -28,7 +28,7 @@ class Organization(ApiObject):
|
||||||
return hash(self.gitea) ^ hash(self.name)
|
return hash(self.gitea) ^ hash(self.name)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def request(cls, gitea: 'Gitea', name: str):
|
def request(cls, gitea: 'Gitea', name: str) -> 'Organization':
|
||||||
return cls._request(gitea, {"name": name})
|
return cls._request(gitea, {"name": name})
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -363,7 +363,7 @@ class Repository(ApiObject):
|
||||||
def get_full_name(self) -> str:
|
def get_full_name(self) -> str:
|
||||||
return self.owner.username + "/" + self.name
|
return self.owner.username + "/" + self.name
|
||||||
|
|
||||||
def create_issue(self, title, assignees=[], description="") -> ApiObject:
|
def create_issue(self, title, assignees=frozenset(), description="") -> ApiObject:
|
||||||
data = {
|
data = {
|
||||||
"assignees": assignees,
|
"assignees": assignees,
|
||||||
"body": description,
|
"body": description,
|
||||||
|
@ -542,7 +542,7 @@ class Commit(ReadonlyApiObject):
|
||||||
return hash(self.sha)
|
return hash(self.sha)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def parse_response(cls, gitea, result):
|
def parse_response(cls, gitea, result) -> 'Commit':
|
||||||
commit_cache = result["commit"]
|
commit_cache = result["commit"]
|
||||||
api_object = cls(gitea)
|
api_object = cls(gitea)
|
||||||
cls._initialize(gitea, api_object, result)
|
cls._initialize(gitea, api_object, result)
|
||||||
|
|
|
@ -47,7 +47,6 @@ class ReadonlyApiObject:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _initialize(cls, gitea, api_object, result):
|
def _initialize(cls, gitea, api_object, result):
|
||||||
x = 1
|
|
||||||
for name, value in result.items():
|
for name, value in result.items():
|
||||||
if name in cls._fields_to_parsers and value is not None:
|
if name in cls._fields_to_parsers and value is not None:
|
||||||
parse_func = cls._fields_to_parsers[name]
|
parse_func = cls._fields_to_parsers[name]
|
||||||
|
@ -63,7 +62,7 @@ class ReadonlyApiObject:
|
||||||
if not hasattr(api_object, name):
|
if not hasattr(api_object, name):
|
||||||
setattr(api_object, "_" + name, value)
|
setattr(api_object, "_" + name, value)
|
||||||
prop = property(
|
prop = property(
|
||||||
(lambda name: lambda self: self._get_var(name))(name))
|
(lambda n: lambda self: self._get_var(n))(name))
|
||||||
setattr(cls, name, prop)
|
setattr(cls, name, prop)
|
||||||
else:
|
else:
|
||||||
raise AttributeError(f"Attribute {name} already exists on api object.")
|
raise AttributeError(f"Attribute {name} already exists on api object.")
|
||||||
|
@ -107,8 +106,8 @@ class ApiObject(ReadonlyApiObject):
|
||||||
if not hasattr(api_object, "_" + name):
|
if not hasattr(api_object, "_" + name):
|
||||||
setattr(api_object, "_" + name, value)
|
setattr(api_object, "_" + name, value)
|
||||||
prop = property(
|
prop = property(
|
||||||
(lambda name: lambda self: self._get_var(name))(name),
|
(lambda n: lambda self: self._get_var(n))(name),
|
||||||
(lambda name: lambda self, v: self.__set_var(name, v))(name))
|
(lambda n: lambda self, v: self.__set_var(n, v))(name))
|
||||||
setattr(cls, name, prop)
|
setattr(cls, name, prop)
|
||||||
|
|
||||||
def __set_var(self, name, i):
|
def __set_var(self, name, i):
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
requests
|
requests
|
||||||
httpcache
|
httpcache
|
||||||
pytest
|
pytest
|
||||||
|
frozendict
|
||||||
|
|
Ładowanie…
Reference in New Issue