Spaces:
Sleeping
Sleeping
Download verify_reports.py from Shivam4096/Financial2API: direct link, hf CLI and curl.
- Browser
- Download file 1.48 kB
-
https://huggingface.co/spaces/Shivam4096/Financial2API/resolve/main/verify_reports.py
- Command line
-
hf download hf://spaces/Shivam4096/Financial2API/verify_reports.py
-
curl -L -o verify_reports.py https://huggingface.co/spaces/Shivam4096/Financial2API/resolve/main/verify_reports.py
1.48 kB
| import sys, io, os | |
| sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') | |
| sys.path.insert(0, '.') | |
| from pipeline.resolver import resolve | |
| from pipeline.fetcher import fetch_all | |
| from pipeline.calculator import calculate | |
| from pipeline.analyst import generate_narrative | |
| from builders.build_excel import build_workbook | |
| from builders.build_docx import build_document | |
| def run_test(): | |
| print("1. Resolving TCS...") | |
| meta = resolve('TCS', log_fn=lambda m: print(" " + m)) | |
| print("\n2. Fetching data...") | |
| data = fetch_all(meta, years=5, force_refresh=False, log_fn=lambda m: print(" " + m)) | |
| print("\n3. Calculating ratios...") | |
| data = calculate(data, meta.to_dict()) | |
| print("\n4. Generating Narrative (Data-only)...") | |
| # Use empty models list to skip actual API calls for a quick formatting test | |
| narrative = generate_narrative(data, meta.to_dict(), models=[], log_fn=lambda m: print(" " + m)) | |
| data.update(narrative) | |
| # Save test files | |
| os.makedirs("test_outputs", exist_ok=True) | |
| excel_path = "test_outputs/TCS_Analysis.xlsx" | |
| docx_path = "test_outputs/TCS_Analysis.docx" | |
| print("\n5. Building Excel...") | |
| build_workbook(data, excel_path) | |
| print(f" ✓ Saved to {excel_path}") | |
| print("\n6. Building Word Document...") | |
| build_document(data, docx_path) | |
| print(f" ✓ Saved to {docx_path}") | |
| print("\nAll tests passed successfully!") | |
| if __name__ == "__main__": | |
| run_test() | |