~huyngo/gh-migrate

68741f943974f49e3fa5ec90a14fd8e600464f50 — Ngô Ngọc Đức Huy 5 months ago 3699a9c
Add some draft
3 files changed, 44 insertions(+), 0 deletions(-)

A config-example.json
A config.py
A github_dl.py
A config-example.json => config-example.json +9 -0
@@ 0,0 1,9 @@
{
  "github": {
    "user": "go-gitea",
    "repo": "gitea",
    "rate_limit": 5000,
    "page_length": 100,
    "token": "xyz"
  }
}

A config.py => config.py +23 -0
@@ 0,0 1,23 @@
import json


class APIConfig:
    user: str
    repo: str
    rate_limit: int
    page_length: int
    token: str

    def __init__(self, config: dict):
        self.user = config['user']
        self.repo = config['repo']
        self.rate_limit = config['rate_limit']
        self.page_length = config['page_length']
        self.token = config['token']


def get_config(forge: str) -> APIConfig:
    """Get config for relevant forge."""
    with open('config.json', 'r') as f:
        config = json.dump(f)
        return config[forge]

A github_dl.py => github_dl.py +12 -0
@@ 0,0 1,12 @@
#!/usr/bin/env python3

import json
from urllib.request import urlopen

from .config import get_config

config = get_config('github')


def parse_issue(issue: dict):
    pass