kopia lustrzana https://github.com/Langenfeld/py-gitea
add delete_time, fix some bugs
rodzic
1a3f93b33d
commit
60486a0ce9
|
@ -2,7 +2,7 @@ import json
|
||||||
import logging
|
import logging
|
||||||
import uuid
|
import uuid
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import List, Tuple, Dict, Sequence
|
from typing import List, Tuple, Dict, Sequence, Optional
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from httpcache import CachingHTTPAdapter
|
from httpcache import CachingHTTPAdapter
|
||||||
|
@ -261,7 +261,7 @@ class Repository(GiteaApiObject):
|
||||||
|
|
||||||
def get_issues(self) -> List["Issue"]:
|
def get_issues(self) -> List["Issue"]:
|
||||||
"""Get all Issues of this Repository (open and closed)"""
|
"""Get all Issues of this Repository (open and closed)"""
|
||||||
return self.get_issues_state(Issue.open) + self.get_issues_state(Issue.closed)
|
return self.get_issues_state(Issue.OPENED) + self.get_issues_state(Issue.CLOSED)
|
||||||
|
|
||||||
def get_commits(self) -> List["Commit"]:
|
def get_commits(self) -> List["Commit"]:
|
||||||
"""Get all the Commits of this Repository."""
|
"""Get all the Commits of this Repository."""
|
||||||
|
@ -439,6 +439,7 @@ class Issue(GiteaApiObject):
|
||||||
GET_TIME = """/repos/%s/%s/issues/%s/times""" # <owner, repo, index>
|
GET_TIME = """/repos/%s/%s/issues/%s/times""" # <owner, repo, index>
|
||||||
GET_COMMENTS = """/repos/%s/%s/issues/comments"""
|
GET_COMMENTS = """/repos/%s/%s/issues/comments"""
|
||||||
CREATE_ISSUE = """/repos/{owner}/{repo}/issues"""
|
CREATE_ISSUE = """/repos/{owner}/{repo}/issues"""
|
||||||
|
DELETE_TIME = """/repos/{owner}/{repo}/issues/{index}/times/{id}"""
|
||||||
|
|
||||||
OPENED = "closed"
|
OPENED = "closed"
|
||||||
CLOSED = "open"
|
CLOSED = "open"
|
||||||
|
@ -478,7 +479,7 @@ class Issue(GiteaApiObject):
|
||||||
result = gitea.requests_post(Issue.CREATE_ISSUE.format(**args), data=data)
|
result = gitea.requests_post(Issue.CREATE_ISSUE.format(**args), data=data)
|
||||||
return Issue.parse_response(gitea, result)
|
return Issue.parse_response(gitea, result)
|
||||||
|
|
||||||
def get_time(self, user: User) -> int:
|
def get_time_sum(self, user: User) -> int:
|
||||||
results = self.gitea.requests_get(
|
results = self.gitea.requests_get(
|
||||||
Issue.GET_TIME % (self.owner.username, self.repo, self.number)
|
Issue.GET_TIME % (self.owner.username, self.repo, self.number)
|
||||||
)
|
)
|
||||||
|
@ -488,6 +489,16 @@ class Issue(GiteaApiObject):
|
||||||
if result and result["user_id"] == user.id
|
if result and result["user_id"] == user.id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def get_times(self) -> Optional[Dict]:
|
||||||
|
return self.gitea.requests_get(
|
||||||
|
Issue.GET_TIME % (self.owner.username, self.repo, self.number)
|
||||||
|
)
|
||||||
|
|
||||||
|
def delete_time(self, time_id: str):
|
||||||
|
self.gitea.requests_delete(
|
||||||
|
Issue.DELETE_TIME % (self.owner.username, self.repo, self.number, time_id)
|
||||||
|
)
|
||||||
|
|
||||||
def get_comments(self) -> List[GiteaApiObject]:
|
def get_comments(self) -> List[GiteaApiObject]:
|
||||||
results = self.gitea.requests_get(
|
results = self.gitea.requests_get(
|
||||||
Issue.GET_COMMENTS % (self.owner.username, self.repo)
|
Issue.GET_COMMENTS % (self.owner.username, self.repo)
|
||||||
|
|
Ładowanie…
Reference in New Issue