From 4951c06b700381f9c68d8a24a2ee215f014bdb86 Mon Sep 17 00:00:00 2001 From: sangge-rockpi <2251250136@qq.com> Date: Mon, 22 Jan 2024 00:55:46 +0800 Subject: [PATCH] update --- action.yml | 12 ++++++ main.py | 101 +++++++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 1 + 3 files changed, 114 insertions(+) create mode 100644 action.yml create mode 100644 main.py create mode 100644 requirements.txt diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..5b376af --- /dev/null +++ b/action.yml @@ -0,0 +1,12 @@ +name: "Leetcode - Readme" +author: "Smart-SangGe" +description: "Leetcode graph in your profile readme" + +inputs: + LEETCODE_USERNAME: + description: "Leetcode username" + required: true + +runs: + using: "docker" + image: "dockerfile" diff --git a/main.py b/main.py new file mode 100644 index 0000000..cb2a15a --- /dev/null +++ b/main.py @@ -0,0 +1,101 @@ +""" +Leetcode status visualizer! +Contains status bar and skills box + +status bar like this: + +```txt +Total solved: xxx + +Easy: xxx/xxx Beats xx% +XXXX.......... + +Medium: xxx/xxx Beats xx% +XXXX.......... + +Hard: xxx/xxx Beats xx% +XXXX.......... +``` + +skills box like this: + +```txt +Top Leetcode Skills + +1. Divide and Conquer (1) XXXXX..... Advanced +2. Trie (1) XXXXX..... Advanced +3. Hash Table (1) XXXXX..... Intermediate +4. Math (3) XXXXX..... Intermediate +5. Recursion (1) XX........ Intermediate +``` +""" + +# standard +import sys +import os +from dataclasses import dataclass + + +# external + +from gitea import * +import requests + +############## data ################## + + +@dataclass(slots=True) +class LeetcodeInput: + """Leetcode Input Env Varidables.""" + + # constants + prefix_length: int = 16 + graph_length: int = 25 + + # mapped env var + # # required + gitea_token: str = os.getenv("GITHUB_TOKEN") + gitea_url: str = os.getenv("GITHUB_SERVER_URL") + leetcode_username: str = os.getenv("USERNAME") + + # # depends + commit_message: str = os.getenv("INPUT_COMMIT_MESSAGE", "Update leetcode status") + + def validate_input(self) -> bool: + """Validate Input Env Var""" + if not self.gitea_token or not self.gitea_url or not self.leetcode_username: + return False + return True + + +############# logic ################### + + +def make_title() -> str: + """Count total solved number""" + pass + + +def make_graph() -> str: + """Make graph from the API's data""" + pass + + +def fetch_data() -> str: + """Fetch data from leetcode api""" + pass + + +def genesis() -> None: + pass + + +if __name__ == "__main__": + lc_i = LeetcodeInput() + if not lc_i.validate_input(): + print("Input error") + sys.exit(1) + + genesis() + + print("\nThanks for using Leetcode readme") diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..bb723ea --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +py-gitea>=0.2.6