From bdf00e6324334bc8aae7c5bbb229e562d9f48b38 Mon Sep 17 00:00:00 2001 From: randomuser Date: Sun, 24 Mar 2024 18:15:31 -0500 Subject: [PATCH] temporary commit (read desc) **This commit needs to be squashed!** - establish general project structure - put together a simple gitea wrapper - probably should be replaced with giteapy (see README.md) --- gitea_github_sync/__init__.py | 0 gitea_github_sync/__main__.py | 3 +++ gitea_github_sync/cli.py | 2 ++ gitea_github_sync/gitea/__init__.py | 0 gitea_github_sync/gitea/__main__.py | 1 + gitea_github_sync/gitea/issues.py | 2 ++ gitea_github_sync/gitea/repo.py | 35 +++++++++++++++++++++++++++++ 7 files changed, 43 insertions(+) create mode 100644 gitea_github_sync/__init__.py create mode 100644 gitea_github_sync/__main__.py create mode 100644 gitea_github_sync/cli.py create mode 100644 gitea_github_sync/gitea/__init__.py create mode 100644 gitea_github_sync/gitea/__main__.py create mode 100644 gitea_github_sync/gitea/issues.py create mode 100644 gitea_github_sync/gitea/repo.py diff --git a/gitea_github_sync/__init__.py b/gitea_github_sync/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/gitea_github_sync/__main__.py b/gitea_github_sync/__main__.py new file mode 100644 index 0000000..d92dc90 --- /dev/null +++ b/gitea_github_sync/__main__.py @@ -0,0 +1,3 @@ +from cli import main + +main() diff --git a/gitea_github_sync/cli.py b/gitea_github_sync/cli.py new file mode 100644 index 0000000..bafb42d --- /dev/null +++ b/gitea_github_sync/cli.py @@ -0,0 +1,2 @@ +import argparse + diff --git a/gitea_github_sync/gitea/__init__.py b/gitea_github_sync/gitea/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/gitea_github_sync/gitea/__main__.py b/gitea_github_sync/gitea/__main__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/gitea_github_sync/gitea/__main__.py @@ -0,0 +1 @@ + diff --git a/gitea_github_sync/gitea/issues.py b/gitea_github_sync/gitea/issues.py new file mode 100644 index 0000000..1bc7e58 --- /dev/null +++ b/gitea_github_sync/gitea/issues.py @@ -0,0 +1,2 @@ +class GiteaIssue: + diff --git a/gitea_github_sync/gitea/repo.py b/gitea_github_sync/gitea/repo.py new file mode 100644 index 0000000..41dc44a --- /dev/null +++ b/gitea_github_sync/gitea/repo.py @@ -0,0 +1,35 @@ +from urllib.parse import urlparse + +def urlparse_w(url): + parseresult = urlparse(url) + splitted_path = parseresult.path.split('/') + + # add some more metadata + gitea_username = splitted_path[1] + gitea_reponame = splitted_path[2] + + return { + "raw": parseresult, + "username": gitea_username, + "reponame": gitea_reponame, + } + +class GiteaRepo: + def __init__(self, urlspec): + """ + Return a GiteaRepo from a urlspec (see urllib.parse.ParseResult) and some other metadata + + For implementation details, see urlparse_w. + + If you want to take an actual url, use the .from_url classmethod. + """ + self.urlspec = urlspec + + @classmethod + def from_url(cls, url): + """ + Return a GiteaRepo from a url. + """ + + parsed = urlparse_w(url) + return cls(parsed)