Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,8 @@ import time
|
|
| 6 |
from typing import List, Tuple
|
| 7 |
import re
|
| 8 |
import pandas as pd
|
| 9 |
-
|
|
|
|
| 10 |
import dash
|
| 11 |
import dash_bootstrap_components as dbc
|
| 12 |
from dash import html, dcc, Input, Output, State, ctx, dash_table
|
|
@@ -436,7 +437,12 @@ def update_r_review_output(n_clicks, contents, filename, red_doc, requirements):
|
|
| 436 |
def download_shred(n_clicks, shred_output):
|
| 437 |
if shred_output is None:
|
| 438 |
return dash.no_update
|
| 439 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 440 |
|
| 441 |
@app.callback(
|
| 442 |
Output("download-pink-doc", "data"),
|
|
@@ -447,7 +453,12 @@ def download_shred(n_clicks, shred_output):
|
|
| 447 |
def download_pink(n_clicks, pink_output):
|
| 448 |
if pink_output is None:
|
| 449 |
return dash.no_update
|
| 450 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 451 |
|
| 452 |
@app.callback(
|
| 453 |
Output("download-p-review-doc", "data"),
|
|
@@ -458,7 +469,12 @@ def download_pink(n_clicks, pink_output):
|
|
| 458 |
def download_p_review(n_clicks, p_review_output):
|
| 459 |
if p_review_output is None:
|
| 460 |
return dash.no_update
|
| 461 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 462 |
|
| 463 |
@app.callback(
|
| 464 |
Output("download-red-doc", "data"),
|
|
@@ -469,7 +485,12 @@ def download_p_review(n_clicks, p_review_output):
|
|
| 469 |
def download_red(n_clicks, red_output):
|
| 470 |
if red_output is None:
|
| 471 |
return dash.no_update
|
| 472 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 473 |
|
| 474 |
@app.callback(
|
| 475 |
Output("download-r-review-doc", "data"),
|
|
@@ -480,7 +501,12 @@ def download_red(n_clicks, red_output):
|
|
| 480 |
def download_r_review(n_clicks, r_review_output):
|
| 481 |
if r_review_output is None:
|
| 482 |
return dash.no_update
|
| 483 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 484 |
|
| 485 |
@app.callback(
|
| 486 |
Output("download-g-review-doc", "data"),
|
|
@@ -491,7 +517,12 @@ def download_r_review(n_clicks, r_review_output):
|
|
| 491 |
def download_g_review(n_clicks, g_review_output):
|
| 492 |
if g_review_output is None:
|
| 493 |
return dash.no_update
|
| 494 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 495 |
|
| 496 |
@app.callback(
|
| 497 |
Output("download-loe-doc", "data"),
|
|
@@ -502,8 +533,15 @@ def download_g_review(n_clicks, g_review_output):
|
|
| 502 |
def download_loe(n_clicks, loe_output):
|
| 503 |
if loe_output is None:
|
| 504 |
return dash.no_update
|
| 505 |
-
|
| 506 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 507 |
|
| 508 |
if __name__ == '__main__':
|
| 509 |
print("Starting the Dash application...")
|
|
|
|
| 6 |
from typing import List, Tuple
|
| 7 |
import re
|
| 8 |
import pandas as pd
|
| 9 |
+
from docx import Document
|
| 10 |
+
from io import BytesIO
|
| 11 |
import dash
|
| 12 |
import dash_bootstrap_components as dbc
|
| 13 |
from dash import html, dcc, Input, Output, State, ctx, dash_table
|
|
|
|
| 437 |
def download_shred(n_clicks, shred_output):
|
| 438 |
if shred_output is None:
|
| 439 |
return dash.no_update
|
| 440 |
+
content = shred_output['props']['children'] if isinstance(shred_output, dict) else str(shred_output)
|
| 441 |
+
doc = create_docx(content)
|
| 442 |
+
buffer = BytesIO()
|
| 443 |
+
doc.save(buffer)
|
| 444 |
+
buffer.seek(0)
|
| 445 |
+
return dcc.send_bytes(buffer.getvalue(), "shred_outline.docx")
|
| 446 |
|
| 447 |
@app.callback(
|
| 448 |
Output("download-pink-doc", "data"),
|
|
|
|
| 453 |
def download_pink(n_clicks, pink_output):
|
| 454 |
if pink_output is None:
|
| 455 |
return dash.no_update
|
| 456 |
+
content = pink_output['props']['children'] if isinstance(pink_output, dict) else str(pink_output)
|
| 457 |
+
doc = create_docx(content)
|
| 458 |
+
buffer = BytesIO()
|
| 459 |
+
doc.save(buffer)
|
| 460 |
+
buffer.seek(0)
|
| 461 |
+
return dcc.send_bytes(buffer.getvalue(), "pink_team_document.docx")
|
| 462 |
|
| 463 |
@app.callback(
|
| 464 |
Output("download-p-review-doc", "data"),
|
|
|
|
| 469 |
def download_p_review(n_clicks, p_review_output):
|
| 470 |
if p_review_output is None:
|
| 471 |
return dash.no_update
|
| 472 |
+
content = p_review_output['props']['children'] if isinstance(p_review_output, dict) else str(p_review_output)
|
| 473 |
+
doc = create_docx(content)
|
| 474 |
+
buffer = BytesIO()
|
| 475 |
+
doc.save(buffer)
|
| 476 |
+
buffer.seek(0)
|
| 477 |
+
return dcc.send_bytes(buffer.getvalue(), "p_review_report.docx")
|
| 478 |
|
| 479 |
@app.callback(
|
| 480 |
Output("download-red-doc", "data"),
|
|
|
|
| 485 |
def download_red(n_clicks, red_output):
|
| 486 |
if red_output is None:
|
| 487 |
return dash.no_update
|
| 488 |
+
content = red_output['props']['children'] if isinstance(red_output, dict) else str(red_output)
|
| 489 |
+
doc = create_docx(content)
|
| 490 |
+
buffer = BytesIO()
|
| 491 |
+
doc.save(buffer)
|
| 492 |
+
buffer.seek(0)
|
| 493 |
+
return dcc.send_bytes(buffer.getvalue(), "red_team_document.docx")
|
| 494 |
|
| 495 |
@app.callback(
|
| 496 |
Output("download-r-review-doc", "data"),
|
|
|
|
| 501 |
def download_r_review(n_clicks, r_review_output):
|
| 502 |
if r_review_output is None:
|
| 503 |
return dash.no_update
|
| 504 |
+
content = r_review_output['props']['children'] if isinstance(r_review_output, dict) else str(r_review_output)
|
| 505 |
+
doc = create_docx(content)
|
| 506 |
+
buffer = BytesIO()
|
| 507 |
+
doc.save(buffer)
|
| 508 |
+
buffer.seek(0)
|
| 509 |
+
return dcc.send_bytes(buffer.getvalue(), "r_review_report.docx")
|
| 510 |
|
| 511 |
@app.callback(
|
| 512 |
Output("download-g-review-doc", "data"),
|
|
|
|
| 517 |
def download_g_review(n_clicks, g_review_output):
|
| 518 |
if g_review_output is None:
|
| 519 |
return dash.no_update
|
| 520 |
+
content = g_review_output['props']['children'] if isinstance(g_review_output, dict) else str(g_review_output)
|
| 521 |
+
doc = create_docx(content)
|
| 522 |
+
buffer = BytesIO()
|
| 523 |
+
doc.save(buffer)
|
| 524 |
+
buffer.seek(0)
|
| 525 |
+
return dcc.send_bytes(buffer.getvalue(), "g_review_report.docx")
|
| 526 |
|
| 527 |
@app.callback(
|
| 528 |
Output("download-loe-doc", "data"),
|
|
|
|
| 533 |
def download_loe(n_clicks, loe_output):
|
| 534 |
if loe_output is None:
|
| 535 |
return dash.no_update
|
| 536 |
+
if isinstance(loe_output, list) and len(loe_output) > 0:
|
| 537 |
+
content = loe_output[0]['props']['children'] if isinstance(loe_output[0], dict) else str(loe_output[0])
|
| 538 |
+
else:
|
| 539 |
+
content = str(loe_output)
|
| 540 |
+
doc = create_docx(content)
|
| 541 |
+
buffer = BytesIO()
|
| 542 |
+
doc.save(buffer)
|
| 543 |
+
buffer.seek(0)
|
| 544 |
+
return dcc.send_bytes(buffer.getvalue(), "loe_report.docx")
|
| 545 |
|
| 546 |
if __name__ == '__main__':
|
| 547 |
print("Starting the Dash application...")
|