add .gitignore and env.yml,避免github相关信息泄露和灵活配置
This commit is contained in:
parent
8c2b1d429f
commit
80f69b0836
|
|
@ -0,0 +1,12 @@
|
|||
# GitHub Configuration
|
||||
github_token: ghp_your_github_token_here
|
||||
|
||||
# GitHub API Configuration
|
||||
base_url: https://api.github.com
|
||||
min_stars: 20
|
||||
request_interval: 0.8
|
||||
max_retry_5xx: 3
|
||||
|
||||
# Clone Configuration
|
||||
clone_retry: 2
|
||||
clone_timeout: 180
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
# Environment files
|
||||
.env.yml
|
||||
.env
|
||||
|
||||
# Python
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
|
||||
# Logs
|
||||
logs/
|
||||
*.log
|
||||
|
||||
# Data directories
|
||||
data/
|
||||
|
||||
# IDE
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
|
@ -1,2 +1,9 @@
|
|||
# benchmark
|
||||
|
||||
## 开发模式
|
||||
|
||||
- 创建环境变量文件
|
||||
|
||||
```
|
||||
cp .env.example.yml .env.yml
|
||||
```
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import json
|
|||
import xml.etree.ElementTree as ET
|
||||
import subprocess
|
||||
import re
|
||||
import yaml
|
||||
|
||||
# 路径配置
|
||||
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
|
@ -24,20 +25,34 @@ MISSING_REPO_LOG = os.path.join(LOG_DIR, "missing_repo.log")
|
|||
for d in [DATA_DIR, REPO_DIR, LOG_DIR]:
|
||||
os.makedirs(d, exist_ok=True)
|
||||
|
||||
# 读取配置文件
|
||||
def load_config():
|
||||
config_path = os.path.join(SCRIPT_DIR, ".env.yml")
|
||||
if not os.path.exists(config_path):
|
||||
print(f"Config file not found: {config_path}")
|
||||
print(f"Please create it based on .env.example.yml")
|
||||
exit(1)
|
||||
|
||||
with open(config_path, "r") as f:
|
||||
return yaml.safe_load(f)
|
||||
|
||||
# 加载配置
|
||||
config = load_config()
|
||||
|
||||
# GitHub 配置
|
||||
GITHUB_TOKEN = os.getenv("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")
|
||||
GITHUB_TOKEN = config.get("github_token")
|
||||
HEADERS = {"Accept": "application/vnd.github+json"}
|
||||
if GITHUB_TOKEN:
|
||||
HEADERS["Authorization"] = f"token {GITHUB_TOKEN}"
|
||||
|
||||
BASE_URL = "https://api.github.com"
|
||||
MIN_STARS = 20
|
||||
REQUEST_INTERVAL = 0.8
|
||||
MAX_RETRY_5XX = 3
|
||||
BASE_URL = config.get("base_url", "https://api.github.com")
|
||||
MIN_STARS = config.get("min_stars", 20)
|
||||
REQUEST_INTERVAL = config.get("request_interval", 0.8)
|
||||
MAX_RETRY_5XX = config.get("max_retry_5xx", 3)
|
||||
|
||||
# clone 控制参数
|
||||
CLONE_RETRY = 2
|
||||
CLONE_TIMEOUT = 180
|
||||
CLONE_RETRY = config.get("clone_retry", 2)
|
||||
CLONE_TIMEOUT = config.get("clone_timeout", 180)
|
||||
|
||||
# 日志工具
|
||||
def log_to_file(path, msg):
|
||||
|
|
|
|||
Loading…
Reference in New Issue