move gitea issues to todoist
This commit is contained in:
commit
fe4cf08221
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
config.ini
|
14
config.ini-dist
Normal file
14
config.ini-dist
Normal file
@ -0,0 +1,14 @@
|
||||
[auth]
|
||||
gitea_url = https://git.cynarski.pl
|
||||
gitea_token =
|
||||
todoist_login =
|
||||
todoist_pass =
|
||||
|
||||
[gitea_projects]
|
||||
sCRM/apiServer = sCRM
|
||||
sCRM/apiClient = sCRM
|
||||
Apartamenty/apiServer = Apartamenty
|
||||
Apartamenty/apiWebClient = Apartamenty
|
||||
Apartamenty/NukiSDK = Apartamenty
|
||||
Apartamenty/BaseDocker = Apartamenty
|
||||
|
77
todoist.py
Executable file
77
todoist.py
Executable file
@ -0,0 +1,77 @@
|
||||
#!/bin/env python
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
import pytea
|
||||
import sys
|
||||
import json
|
||||
import configparser
|
||||
import marshmallow.validate
|
||||
|
||||
from dataclasses import field
|
||||
from marshmallow_dataclass import dataclass
|
||||
from typing import List, Optional
|
||||
from pytodoist import todoist
|
||||
from pprint import pprint
|
||||
from types import SimpleNamespace as Namespace
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.read('./config.ini')
|
||||
logging.basicConfig(stream=sys.stderr, level=logging.INFO, format='%(asctime)s %(levelname)s %(filename)s: %(message)s')
|
||||
logger = logging.getLogger("todoist-im")
|
||||
|
||||
@dataclass
|
||||
class GiteaUser:
|
||||
avatar_url: str
|
||||
full_name: str
|
||||
id: int
|
||||
is_admin: bool
|
||||
language: str
|
||||
login: str
|
||||
username: str
|
||||
|
||||
@dataclass
|
||||
class GiteaIssue:
|
||||
id: int
|
||||
number: int
|
||||
assignee: Optional[GiteaUser]
|
||||
body: str
|
||||
user: Optional[GiteaUser]
|
||||
title: str
|
||||
url: str
|
||||
|
||||
# args = parser.parse_args()
|
||||
# print(args.accumulate(args.integers))
|
||||
|
||||
gitea = pytea.API(config['auth']['gitea_url'], token=config['auth']['gitea_token'])
|
||||
todo = todoist.login(config['auth']['todoist_login'], config['auth']['todoist_pass'])
|
||||
|
||||
userJson = gitea.get("/user").json()
|
||||
user, _ = GiteaUser.Schema().load(userJson)
|
||||
|
||||
for giteaProject in config['gitea_projects']:
|
||||
logger.info("Scanning ... https://git.cynarski.pl/" + giteaProject)
|
||||
totdoistProject = config['gitea_projects'][giteaProject]
|
||||
issuesJson = json.loads(gitea.get("/repos/"+giteaProject.strip()+"/issues" , params={"state": "open", "page": 0}).text)
|
||||
todoProject = todo.get_project(totdoistProject)
|
||||
tasks = todoProject.get_tasks()
|
||||
|
||||
for issueJson in issuesJson:
|
||||
addTask = True
|
||||
issue, _ = GiteaIssue.Schema().load(issueJson)
|
||||
|
||||
for task in tasks:
|
||||
if issue.title == task.content:
|
||||
logger.info("Task exists in todoist ... %r", issue.title)
|
||||
addTask = False
|
||||
|
||||
|
||||
if addTask:
|
||||
pprint(addTask)
|
||||
pprint(issue.title)
|
||||
logger.info("Adding ... %r", issue.title)
|
||||
task = todoProject.add_task(issue.title)
|
||||
task.add_note("https://git.cynarski.pl/"+giteaProject+"/issues/"+str(issue.number))
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user