Spaces:
Runtime error
Runtime error
Download utils/formatters.py from UNIQ-Project-AI/uniq-backendd: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/spaces/UNIQ-Project-AI/uniq-backendd/resolve/main/utils/formatters.py
- Command line
-
hf download hf://spaces/UNIQ-Project-AI/uniq-backendd/utils/formatters.py
-
curl -L -o formatters.py https://huggingface.co/spaces/UNIQ-Project-AI/uniq-backendd/resolve/main/utils/formatters.py
1.25 kB
| def format_course_results(results, COURSES_CATALOG): | |
| if not results: | |
| return "للأسف مش لاقي بيانات للمواد دي حالياً." | |
| formatted = [] | |
| for r in results: | |
| course = r.get("course", "Unknown") | |
| course_code = COURSES_CATALOG.get(course, {}).get("code", "") | |
| eligible = r.get("eligible", False) | |
| if eligible: | |
| status = "✅ متاح لك تسجلها" | |
| if r.get("gpa") is not None: | |
| status += f" (معدل أدائك في متطلباتها: {r['gpa']:.2f})" | |
| else: | |
| reasons = [] | |
| if r.get("missing"): | |
| reasons.append("مش واخد: " + " و ".join(r["missing"])) | |
| if r.get("failed"): | |
| reasons.append("راسب في: " + " و ".join(r["failed"])) | |
| if r.get("incomplete"): | |
| reasons.append("غير مكتمل: " + " و ".join(r["incomplete"])) | |
| if not reasons: | |
| reasons.append(r.get("reason", "لم يتم استيفاء الشروط")) | |
| status = "❌ غير متاح\n " + " | ".join(reasons) | |
| formatted.append(f"📍 **{course}** [{course_code}]\n {status}") | |
| return "\n".join(formatted) |