aboutsummaryrefslogtreecommitdiff
path: root/rss_to_gitea/main.py
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2022-02-08 17:20:47 +0100
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2022-02-08 17:20:47 +0100
commitad3ec123d4543c8cc4106d9d11f6e8e806b90de3 (patch)
treebd444a3337e9db25bc50e271a80e6a53c9ec5bae /rss_to_gitea/main.py
parent1b3996f2faa77e97e4c6bfc88067a2b484611c85 (diff)
downloadatom_to_gitea-ad3ec123d4543c8cc4106d9d11f6e8e806b90de3.tar.gz
working
Diffstat (limited to 'rss_to_gitea/main.py')
-rw-r--r--rss_to_gitea/main.py44
1 files changed, 24 insertions, 20 deletions
diff --git a/rss_to_gitea/main.py b/rss_to_gitea/main.py
index f4425a2..c1a4a11 100644
--- a/rss_to_gitea/main.py
+++ b/rss_to_gitea/main.py
@@ -6,29 +6,33 @@ import sys
from .gitea import GiteaAPI
from .atom import AtomFeed
+from .config import Config
+def print_help():
+ print('''
+USAGE:
+ rsstogitea <config>
+ ''')
-feeds = [
- {
- 'name':'Gitea',
- 'url':'https://github.com/go-gitea/gitea/releases.atom',
- 'exclude':['dev', 'rc'],
- 'assign':''
- }
-]
+def main():
+ if len(sys.argv) <= 1:
+ return 1
-def load_yaml(_file: str):
- required = ['feeds', 'token', 'url']
- config = {}
+ config = Config(sys.argv[1])
+ api = GiteaAPI("https://gitea.my.cum.re", config.token)
- with open(_file, 'r') as f:
- config = yaml.load(f.read(), Loader=yaml.FullLoader)
+ label_id = api.getLabelId(config.owner, config.repo, config.label)
- return config
+ for feed in config.feeds:
+ remote = AtomFeed(feed['url'])
+ latest = remote.get_latest(feed['exclude'], feed['include'])
-def main():
- #token = sys.argv[1]
- #api = GiteaAPI("https://gitea.my.cum.re", token)
- #api.searchIssue('infra', 'ansible', '', 'update')
- feed = AtomFeed(feeds[0]['url'])
- print(feed.get_latest([]))
+ issue_title = f'{feed["name"]}: {latest["title"]}'
+ print("Title=", issue_title)
+
+ ticket = api.searchIssue(config.owner, config.repo, issue_title, [config.label])
+ if ticket is not None:
+ print(f'{issue_title} already exists. Skipping')
+ continue
+
+ result = api.createIssue(config.owner, config.repo, issue_title, '', feed['assign'], [label_id])