hbtn-local-checker 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hbtn_local_checker-1.0.0/PKG-INFO +6 -0
- hbtn_local_checker-1.0.0/README.md +1 -0
- hbtn_local_checker-1.0.0/hbtn_checker/__init__.py +0 -0
- hbtn_local_checker-1.0.0/hbtn_checker/main.py +129 -0
- hbtn_local_checker-1.0.0/hbtn_local_checker.egg-info/PKG-INFO +6 -0
- hbtn_local_checker-1.0.0/hbtn_local_checker.egg-info/SOURCES.txt +10 -0
- hbtn_local_checker-1.0.0/hbtn_local_checker.egg-info/dependency_links.txt +1 -0
- hbtn_local_checker-1.0.0/hbtn_local_checker.egg-info/entry_points.txt +2 -0
- hbtn_local_checker-1.0.0/hbtn_local_checker.egg-info/requires.txt +2 -0
- hbtn_local_checker-1.0.0/hbtn_local_checker.egg-info/top_level.txt +1 -0
- hbtn_local_checker-1.0.0/setup.cfg +4 -0
- hbtn_local_checker-1.0.0/setup.py +16 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# hbtn-local-checker
|
|
File without changes
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import json
|
|
4
|
+
import requests
|
|
5
|
+
import subprocess
|
|
6
|
+
|
|
7
|
+
CONFIG_FILE = os.path.expanduser("~/.hbtn_config.json")
|
|
8
|
+
|
|
9
|
+
def load_config():
|
|
10
|
+
"""İstifadəçi məlumatlarını kompüterin yaddaşından (fayldan) oxuyur."""
|
|
11
|
+
if os.path.exists(CONFIG_FILE):
|
|
12
|
+
with open(CONFIG_FILE, 'r') as f:
|
|
13
|
+
return json.load(f)
|
|
14
|
+
return {}
|
|
15
|
+
|
|
16
|
+
def save_config(student_id, api_key):
|
|
17
|
+
"""Məlumatları növbəti səfərlər üçün yaddaşa yazır."""
|
|
18
|
+
with open(CONFIG_FILE, 'w') as f:
|
|
19
|
+
json.dump({"student_id": student_id, "api_key": api_key}, f)
|
|
20
|
+
print("Məlumatlarınız yaddaşa yazıldı! Növbəti dəfə soruşulmayacaq.")
|
|
21
|
+
|
|
22
|
+
def get_credentials():
|
|
23
|
+
config = load_config()
|
|
24
|
+
student_id = config.get("student_id")
|
|
25
|
+
api_key = config.get("api_key")
|
|
26
|
+
|
|
27
|
+
if not student_id or not api_key:
|
|
28
|
+
print("Salammmmm! Görünür proqramı ilk dəfə işə salırsınız.Helə mii))")
|
|
29
|
+
student_id = input("Holberton Tələbə ID-nizi daxil edin: ").strip()
|
|
30
|
+
api_key = input("Holberton API Açarınızı (Key) daxil edin: ").strip()
|
|
31
|
+
if student_id and api_key:
|
|
32
|
+
save_config(student_id, api_key)
|
|
33
|
+
else:
|
|
34
|
+
print("Xəta: ID və Key mütləqdir!")
|
|
35
|
+
sys.exit(1)
|
|
36
|
+
return student_id, api_key
|
|
37
|
+
|
|
38
|
+
def get_student_projects(student_id, api_key):
|
|
39
|
+
url = f"https://intranet.hbtn.io/api/v1/students/{student_id}/projects"
|
|
40
|
+
headers = {
|
|
41
|
+
"X-API-KEY": str(api_key),
|
|
42
|
+
"cfclearance": "true",
|
|
43
|
+
"Content-Type": "application/json",
|
|
44
|
+
"Accept": "application/json",
|
|
45
|
+
"User-Agent": "Mozilla/5.0"
|
|
46
|
+
}
|
|
47
|
+
try:
|
|
48
|
+
response = requests.get(url, headers=headers, timeout=10)
|
|
49
|
+
if response.status_code == 200:
|
|
50
|
+
return response.json()
|
|
51
|
+
return None
|
|
52
|
+
except Exception:
|
|
53
|
+
return None
|
|
54
|
+
|
|
55
|
+
def parse_active_project(raw_response):
|
|
56
|
+
if isinstance(raw_response, dict) and "items" in raw_response:
|
|
57
|
+
projects_list = raw_response["items"]
|
|
58
|
+
else:
|
|
59
|
+
return []
|
|
60
|
+
|
|
61
|
+
for project in projects_list:
|
|
62
|
+
if isinstance(project, dict):
|
|
63
|
+
if project.get("ended_at") is None or project.get("status") == "active":
|
|
64
|
+
print(f" Aktiv layihə: {project.get('name')}")
|
|
65
|
+
return project.get("tasks", [])
|
|
66
|
+
return []
|
|
67
|
+
|
|
68
|
+
def run_pep8_check(file_name):
|
|
69
|
+
"""Faylın daxilində PEP8 (kod stili) xətası olub-olmadığını yoxlayır."""
|
|
70
|
+
print("PEP8 (pycodestyle) yoxlanılır...")
|
|
71
|
+
try:
|
|
72
|
+
result = subprocess.run(['pycodestyle', file_name], capture_output=True, text=True)
|
|
73
|
+
if result.returncode == 0:
|
|
74
|
+
print(" Style: Əlasızz! Heç bir stil xətası yoxdur.")
|
|
75
|
+
return True
|
|
76
|
+
else:
|
|
77
|
+
print(" Style Xətaları tapıldı:")
|
|
78
|
+
print(result.stdout)
|
|
79
|
+
return False
|
|
80
|
+
except FileNotFoundError:
|
|
81
|
+
print("Sistemdə 'pycodestyle' tapılmadı. 'pip install pycodestyle' edin.")
|
|
82
|
+
return False
|
|
83
|
+
|
|
84
|
+
def run_syntax_check(file_name):
|
|
85
|
+
"""Faylın işlək olub olmadığını və sintaksis xətalarını yoxlayır."""
|
|
86
|
+
print(" Sintaksis və İcra yoxlanılır...")
|
|
87
|
+
result = subprocess.run(['python3', '-m', 'py_compile', file_name], capture_output=True, text=True)
|
|
88
|
+
if result.returncode == 0:
|
|
89
|
+
print(" Sintaksis: Düzgündür, kod xətasız oxunur.")
|
|
90
|
+
return True
|
|
91
|
+
else:
|
|
92
|
+
print(" Sintaksis XƏTASI var:")
|
|
93
|
+
print(result.stderr)
|
|
94
|
+
return False
|
|
95
|
+
|
|
96
|
+
def check_local_files(tasks):
|
|
97
|
+
print("\n LOKAL KODLARIN ANALİZİ BAŞLADI:")
|
|
98
|
+
print("-" * 50)
|
|
99
|
+
|
|
100
|
+
if not tasks:
|
|
101
|
+
print(" API-dən tapşırıq siyahısı gəlmədi. Qovluqdakı mövcud fayllar analiz edilir:\n")
|
|
102
|
+
|
|
103
|
+
python_files = [
|
|
104
|
+
f for f in os.listdir('.')
|
|
105
|
+
if os.path.isfile(f) and f.endswith('.py') and f not in ['checker.py', 'setup.py']
|
|
106
|
+
]
|
|
107
|
+
|
|
108
|
+
if not python_files:
|
|
109
|
+
print(" Qovluqda analiz ediləcək Python faylı tapılmadı.")
|
|
110
|
+
return
|
|
111
|
+
|
|
112
|
+
for f in sorted(python_files):
|
|
113
|
+
print(f"\n Fayl: {f}")
|
|
114
|
+
run_syntax_check(f)
|
|
115
|
+
run_pep8_check(f)
|
|
116
|
+
print("-" * 50)
|
|
117
|
+
return
|
|
118
|
+
|
|
119
|
+
def run():
|
|
120
|
+
print("==========================================")
|
|
121
|
+
print(" HBTN LOCAL CHECKER v1.0.0 ")
|
|
122
|
+
print("==========================================")
|
|
123
|
+
student_id, api_key = get_credentials()
|
|
124
|
+
raw_data = get_student_projects(student_id, api_key)
|
|
125
|
+
active_tasks = parse_active_project(raw_data) if raw_data else []
|
|
126
|
+
check_local_files(active_tasks)
|
|
127
|
+
|
|
128
|
+
if __name__ == "__main__":
|
|
129
|
+
run()
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
setup.py
|
|
3
|
+
hbtn_checker/__init__.py
|
|
4
|
+
hbtn_checker/main.py
|
|
5
|
+
hbtn_local_checker.egg-info/PKG-INFO
|
|
6
|
+
hbtn_local_checker.egg-info/SOURCES.txt
|
|
7
|
+
hbtn_local_checker.egg-info/dependency_links.txt
|
|
8
|
+
hbtn_local_checker.egg-info/entry_points.txt
|
|
9
|
+
hbtn_local_checker.egg-info/requires.txt
|
|
10
|
+
hbtn_local_checker.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
hbtn_checker
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name="hbtn-local-checker",
|
|
5
|
+
version="1.0.0",
|
|
6
|
+
packages=find_packages(),
|
|
7
|
+
install_requires=[
|
|
8
|
+
"requests",
|
|
9
|
+
"pycodestyle",
|
|
10
|
+
],
|
|
11
|
+
entry_points={
|
|
12
|
+
'console_scripts': [
|
|
13
|
+
'hbtn-check=hbtn_checker.main:run',
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
)
|