-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pair report.py with note book and give environment specific root vari…
…ables so can test report generation locally
- Loading branch information
1 parent
f429a50
commit 9677c75
Showing
2 changed files
with
128 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"id": "c6317285-bf98-489f-a858-44925c83f9c3", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"import aspose.words as aw\n", | ||
"import os.path as osp\n", | ||
"from glob import glob\n", | ||
"from pathlib import Path\n", | ||
"\n", | ||
"def main():\n", | ||
" try: \n", | ||
" if os.environ[\"GITHUB_WORKSPACE\"] != None:\n", | ||
" root = os.environ[\"GITHUB_WORKSPACE\"]\n", | ||
" inPath = os.path.join(root, \"TestGraphs\", \"Outputs\")\n", | ||
" \n", | ||
" except: \n", | ||
" rootfrags = os.path.abspath('WS2.py').split(\"\\\\\")\n", | ||
" root = \"\"\n", | ||
" for d in rootfrags:\n", | ||
" if d == \"FieldNBalance\":\n", | ||
" break\n", | ||
" else:\n", | ||
" root += d + \"\\\\\"\n", | ||
" inPath = os.path.join(root,\"FieldNBalance\",\"TestGraphs\", \"Outputs\") \n", | ||
" \n", | ||
" if not osp.isdir(inPath):\n", | ||
" raise FileNotFoundError(f\"Directory does not exist: {inPath}\")\n", | ||
" \n", | ||
" imgs = glob(osp.join(inPath, \"*.png\"))\n", | ||
" if len(imgs) == 0:\n", | ||
" raise FileNotFoundError(f\"No images found in directory: {inPath}\")\n", | ||
" \n", | ||
" doc = aw.Document()\n", | ||
" builder = aw.DocumentBuilder(doc)\n", | ||
"\n", | ||
" for img in imgs:\n", | ||
" builder.insert_image(img)\n", | ||
"\n", | ||
" outdir = \"html\"\n", | ||
" Path(outdir).mkdir(parents=True, exist_ok=True) \n", | ||
" doc.save(osp.join(outdir, \"index.html\"))\n", | ||
"\n", | ||
"if __name__ == \"__main__\":\n", | ||
" main()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "f3ac9d83-1a3d-4c2f-b329-0e91215fc21f", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"jupytext": { | ||
"formats": "ipynb,py:light" | ||
}, | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.13" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters