kopia lustrzana https://github.com/Langenfeld/py-gitea
added polling comments from repositories
rodzic
4dbca7c7f5
commit
9e7696337a
|
@ -366,7 +366,6 @@ class Repository:
|
||||||
index = 1
|
index = 1
|
||||||
issues = []
|
issues = []
|
||||||
while True:
|
while True:
|
||||||
#q=&type=all&sort=&state=open&milestone=0&assignee=0
|
|
||||||
results = self.gitea.requests_get(
|
results = self.gitea.requests_get(
|
||||||
Repository.REPO_ISSUES % (self.owner.username, self.name),
|
Repository.REPO_ISSUES % (self.owner.username, self.name),
|
||||||
params = {"page": index, "state": state}
|
params = {"page": index, "state": state}
|
||||||
|
@ -411,6 +410,7 @@ class Issue:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
GET = """/repos/%s/%s/issues/%s""" # <owner, repo, index>
|
GET = """/repos/%s/%s/issues/%s""" # <owner, repo, index>
|
||||||
|
ISSUE_COMMENTS = """/repos/%s/%s/issues/%s/comments"""
|
||||||
|
|
||||||
def __init__(self, repo: Repository, id: int, initJson: json = None):
|
def __init__(self, repo: Repository, id: int, initJson: json = None):
|
||||||
""" Initializes a Issue.
|
""" Initializes a Issue.
|
||||||
|
@ -455,6 +455,71 @@ class Issue:
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "#%i %s" % (self.id, self.title)
|
return "#%i %s" % (self.id, self.title)
|
||||||
|
|
||||||
|
def get_comments(self):
|
||||||
|
"""Get all the Comments of this Repository.
|
||||||
|
|
||||||
|
Returns: [Comment]
|
||||||
|
A list of Comments of this Repository.
|
||||||
|
"""
|
||||||
|
results = self.gitea.requests_get(
|
||||||
|
Issue.ISSUE_COMMENTS % (self.repository.owner.username, self.repository.name, self.number)
|
||||||
|
)
|
||||||
|
return [Comment(self, result["id"], result) for result in results]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Comment:
|
||||||
|
"""Reperestents Comment in Gitea.
|
||||||
|
"""
|
||||||
|
|
||||||
|
GET = """/repos/%s/%s/issues/comments/%s""" # <owner, repo, index>
|
||||||
|
|
||||||
|
def __init__(self, repo: Repository, id: int, initJson: json = None):
|
||||||
|
""" Initializes a Issue.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
repo (Repository): The Repository of this Issue.
|
||||||
|
id (int): The id of the Issue.
|
||||||
|
initJson (dict): Optional, init information for Issue.
|
||||||
|
|
||||||
|
Warning:
|
||||||
|
This does not create an Issue. <sth> does.
|
||||||
|
|
||||||
|
Throws:
|
||||||
|
NotFoundException, if the Issue could not be found.
|
||||||
|
"""
|
||||||
|
self.gitea = repo.gitea
|
||||||
|
self.__initialize_comment(repo, id, initJson)
|
||||||
|
|
||||||
|
def __initialize_comment(self, repository, id, result):
|
||||||
|
""" Initializing an Comment.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
repo (Repository): The Repository of this Issue.
|
||||||
|
id (int): The id of the Comment.
|
||||||
|
initJson (dict): Optional, init information for Comment.
|
||||||
|
|
||||||
|
Throws:
|
||||||
|
NotFoundException, if the Comment could not be found.
|
||||||
|
"""
|
||||||
|
if not result:
|
||||||
|
result = self.gitea.requests_get(
|
||||||
|
Comment.GET % (repository.owner.username, repository.name, id)
|
||||||
|
)
|
||||||
|
#logging.debug(
|
||||||
|
# "Comment found: %s/%s/%s: %s"
|
||||||
|
# % (repository.owner.username, repository.name, id, result["body"])
|
||||||
|
#)
|
||||||
|
for i, v in result.items():
|
||||||
|
setattr(self, i, v)
|
||||||
|
self.repository = repository
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "#%i %s" % (self.id, self.title)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Branch:
|
class Branch:
|
||||||
""" Represents a Branch in the Gitea-instance.
|
""" Represents a Branch in the Gitea-instance.
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue