Update Doors_Schedule.py
Browse files- Doors_Schedule.py +46 -149
Doors_Schedule.py
CHANGED
|
@@ -1513,30 +1513,26 @@ def mainRun(schedule, plan, searcharray):
|
|
| 1513 |
|
| 1514 |
dfs = extract_tables(schedule)
|
| 1515 |
|
| 1516 |
-
all_new_data = []
|
| 1517 |
-
all_widths = []
|
| 1518 |
-
pdf_outputs = []
|
| 1519 |
|
| 1520 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1521 |
for j in range(len(searcharray)):
|
| 1522 |
-
pdfs = []
|
| 1523 |
user_input = searcharray[j]
|
|
|
|
| 1524 |
secondary_presence = False
|
| 1525 |
-
|
| 1526 |
if user_input[4] or user_input[5]:
|
| 1527 |
secondary_presence = True
|
| 1528 |
-
|
| 1529 |
main_info_, secondary_info_ = separate_main_secondary(user_input)
|
| 1530 |
-
|
| 1531 |
main_info = [item for item in main_info_ if item]
|
| 1532 |
-
secondary_info = [item for item in secondary_info_ if item]
|
| 1533 |
-
|
| 1534 |
print("feh secondary information")
|
| 1535 |
if user_input[4]:
|
| 1536 |
print("Fire rate mawgooda")
|
| 1537 |
if user_input[5]:
|
| 1538 |
print("Acoustic Rate mawgooda")
|
| 1539 |
-
|
| 1540 |
else:
|
| 1541 |
print("mafeesh secondary information")
|
| 1542 |
|
|
@@ -1544,9 +1540,9 @@ def mainRun(schedule, plan, searcharray):
|
|
| 1544 |
kelma = get_st_op_pattern(selected_columns_combined, user_input)
|
| 1545 |
col_dict = get_similar_colors_all(selected_columns_combined)
|
| 1546 |
flattened_list = get_flattened_tuples_list_all(col_dict)
|
| 1547 |
-
|
|
|
|
| 1548 |
if secondary_presence:
|
| 1549 |
-
for p in plan:
|
| 1550 |
plan_texts = read_text(p)
|
| 1551 |
locations, not_found = get_word_locations_plan_secondary(flattened_list,plan_texts, main_info, secondary_info)
|
| 1552 |
new_data3 = get_cleaned_data_secondary(locations,main_info,secondary_info)
|
|
@@ -1560,158 +1556,61 @@ def mainRun(schedule, plan, searcharray):
|
|
| 1560 |
width_info_tobeprinted, secondary_tobeprinted = get_width_info_tobeprinted_secondary(new_data3, main_info, secondary_info)
|
| 1561 |
cleaned_width = get_cleaned_width(width_info_tobeprinted)
|
| 1562 |
widths = get_widths_bb_format(cleaned_width, kelma)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1563 |
secondary_printed_clean = get_secondary_tobeprinted_clean(selected_columns_combined, secondary_tobeprinted, secondary_info)
|
| 1564 |
all_print = mix_width_secondary(widths, secondary_printed_clean)
|
| 1565 |
-
print(f"kelma: {kelma}")
|
| 1566 |
-
|
| 1567 |
-
print(f"width_info_tobeprinted: {width_info_tobeprinted}")
|
| 1568 |
-
print(f"cleaned_width: {cleaned_width}")
|
| 1569 |
-
print(f"widths: {widths}")
|
| 1570 |
|
| 1571 |
#Single page annotation
|
| 1572 |
all_widths.append(all_print)
|
| 1573 |
|
| 1574 |
-
flat_list_new_data = [item for sublist in all_new_data for item in sublist]
|
| 1575 |
-
flat_list_widths = [item for sublist in all_widths for item in sublist]
|
| 1576 |
|
| 1577 |
if pdf_outputs:
|
| 1578 |
final_pdf_bytes = process_pdf_secondary(pdf_outputs[j-1], "final_output_multiple_input_new2.pdf", all_new_data[j], all_widths[j], main_info, secondary_info)
|
| 1579 |
pdf_outputs.append(final_pdf_bytes)
|
| 1580 |
else:
|
| 1581 |
-
final_pdf_bytes = process_pdf_secondary(p, "final_output_multiple_input_new2.pdf",
|
| 1582 |
pdf_outputs.append(final_pdf_bytes)
|
| 1583 |
-
|
| 1584 |
-
pdfs.append(final_pdf_bytes)
|
| 1585 |
-
|
| 1586 |
-
|
| 1587 |
else:
|
| 1588 |
-
|
| 1589 |
-
|
| 1590 |
-
|
| 1591 |
-
|
| 1592 |
-
|
| 1593 |
-
|
| 1594 |
-
|
| 1595 |
-
|
| 1596 |
-
|
| 1597 |
-
|
| 1598 |
-
|
| 1599 |
-
|
| 1600 |
-
|
| 1601 |
-
|
| 1602 |
-
widths = get_widths_bb_format(cleaned_width, kelma)
|
| 1603 |
-
#Single page annotation
|
| 1604 |
-
all_widths.append(widths)
|
| 1605 |
-
|
| 1606 |
-
flat_list_new_data = [item for sublist in all_new_data for item in sublist]
|
| 1607 |
-
flat_list_widths = [item for sublist in all_widths for item in sublist]
|
| 1608 |
-
|
| 1609 |
-
if pdf_outputs:
|
| 1610 |
-
final_pdf_bytes = process_pdf(pdf_outputs[j-1], "final_output_width_trial.pdf", all_new_data[j], all_widths[j])
|
| 1611 |
-
#final_pdf_bytes = process_pdf(p, "final_output_width.pdf", new_data, widths)
|
| 1612 |
-
pdfs.append(final_pdf_bytes)
|
| 1613 |
-
else:
|
| 1614 |
-
final_pdf_bytes = process_pdf(p, "final_output_width_trial.pdf", flat_list_new_data, flat_list_widths)
|
| 1615 |
-
#final_pdf_bytes = process_pdf(p, "final_output_width.pdf", new_data, widths)
|
| 1616 |
-
pdfs.append(final_pdf_bytes)
|
| 1617 |
-
|
| 1618 |
-
#Handling schedules without dimensions (width and height)
|
| 1619 |
-
if selected_columns_combined.shape[1] == 2:
|
| 1620 |
widths = []
|
|
|
|
|
|
|
|
|
|
| 1621 |
|
| 1622 |
-
|
| 1623 |
-
|
| 1624 |
-
|
| 1625 |
-
else:
|
| 1626 |
-
for j in range(len(searcharray)):
|
| 1627 |
-
pdfs = []
|
| 1628 |
-
user_input = searcharray[j]
|
| 1629 |
-
secondary_presence = False
|
| 1630 |
-
|
| 1631 |
-
if user_input[4] or user_input[5]:
|
| 1632 |
-
secondary_presence = True
|
| 1633 |
-
|
| 1634 |
-
main_info_, secondary_info_ = separate_main_secondary(user_input)
|
| 1635 |
-
|
| 1636 |
-
main_info = [item for item in main_info_ if item]
|
| 1637 |
-
secondary_info = [item for item in secondary_info_ if item]
|
| 1638 |
-
|
| 1639 |
-
print("feh secondary information")
|
| 1640 |
-
if user_input[4]:
|
| 1641 |
-
print("Fire rate mawgooda")
|
| 1642 |
-
if user_input[5]:
|
| 1643 |
-
print("Acoustic Rate mawgooda")
|
| 1644 |
-
|
| 1645 |
-
else:
|
| 1646 |
-
print("mafeesh secondary information")
|
| 1647 |
-
|
| 1648 |
-
selected_columns_combined = get_selected_columns_all(dfs, user_input)
|
| 1649 |
-
kelma = get_st_op_pattern(selected_columns_combined, user_input)
|
| 1650 |
-
col_dict = get_similar_colors_all(selected_columns_combined)
|
| 1651 |
-
flattened_list = get_flattened_tuples_list_all(col_dict)
|
| 1652 |
|
| 1653 |
-
|
| 1654 |
-
|
| 1655 |
-
|
| 1656 |
-
|
| 1657 |
-
|
| 1658 |
-
|
| 1659 |
-
#Single page annotation
|
| 1660 |
-
all_new_data.append(new_data3)
|
| 1661 |
-
repeated_labels = get_repeated_labels(locations)
|
| 1662 |
-
if kelma == None:
|
| 1663 |
-
widths, secondary_tobeprinted = get_width_info_tobeprinted_secondary(new_data3, main_info, secondary_info)
|
| 1664 |
-
else:
|
| 1665 |
-
width_info_tobeprinted, secondary_tobeprinted = get_width_info_tobeprinted_secondary(new_data3, main_info, secondary_info)
|
| 1666 |
-
cleaned_width = get_cleaned_width(width_info_tobeprinted)
|
| 1667 |
-
widths = get_widths_bb_format(cleaned_width, kelma)
|
| 1668 |
-
secondary_printed_clean = get_secondary_tobeprinted_clean(selected_columns_combined, secondary_tobeprinted, secondary_info)
|
| 1669 |
-
all_print = mix_width_secondary(widths, secondary_printed_clean)
|
| 1670 |
-
|
| 1671 |
-
#Single page annotation
|
| 1672 |
-
all_widths.append(all_print)
|
| 1673 |
-
|
| 1674 |
-
flat_list_new_data = [item for sublist in all_new_data for item in sublist]
|
| 1675 |
-
flat_list_widths = [item for sublist in all_widths for item in sublist]
|
| 1676 |
-
|
| 1677 |
-
|
| 1678 |
-
final_pdf_bytes = process_pdf_secondary(p, "final_output_multiple_input_new2.pdf", flat_list_new_data, flat_list_widths, main_info, secondary_info)
|
| 1679 |
-
pdfs.append(final_pdf_bytes)
|
| 1680 |
-
|
| 1681 |
-
|
| 1682 |
-
else:
|
| 1683 |
-
for p in plan:
|
| 1684 |
-
print(f" p in plan is {type(p)}")
|
| 1685 |
-
print(p)
|
| 1686 |
-
plan_texts = read_text(p)
|
| 1687 |
-
locations, not_found = get_word_locations_plan(flattened_list,plan_texts)
|
| 1688 |
-
new_data = get_cleaned_data(locations)
|
| 1689 |
-
#Single page annotation
|
| 1690 |
-
all_new_data.append(new_data)
|
| 1691 |
-
repeated_labels = get_repeated_labels(locations)
|
| 1692 |
-
if kelma == None:
|
| 1693 |
-
widths = get_width_info_tobeprinted(new_data)
|
| 1694 |
-
else:
|
| 1695 |
-
width_info_tobeprinted = get_width_info_tobeprinted(new_data)
|
| 1696 |
-
cleaned_width = get_cleaned_width(width_info_tobeprinted)
|
| 1697 |
-
widths = get_widths_bb_format(cleaned_width, kelma)
|
| 1698 |
-
#Single page annotation
|
| 1699 |
-
all_widths.append(widths)
|
| 1700 |
-
|
| 1701 |
-
flat_list_new_data = [item for sublist in all_new_data for item in sublist]
|
| 1702 |
-
flat_list_widths = [item for sublist in all_widths for item in sublist]
|
| 1703 |
-
|
| 1704 |
-
final_pdf_bytes = process_pdf(p, "final_output_width_trial.pdf", flat_list_new_data, flat_list_widths)
|
| 1705 |
-
#final_pdf_bytes = process_pdf(p, "final_output_width.pdf", new_data, widths)
|
| 1706 |
-
pdfs.append(final_pdf_bytes)
|
| 1707 |
|
| 1708 |
-
#Handling schedules without dimensions (width and height)
|
| 1709 |
-
if selected_columns_combined.shape[1] == 2:
|
| 1710 |
-
widths = []
|
| 1711 |
-
|
| 1712 |
-
merged_pdf = merge_pdf_bytes_list(pdfs)
|
| 1713 |
-
print(f"number of pges of merged_pdf is {len(merged_pdf)} and its type is {type(merged_pdf)}")
|
| 1714 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1715 |
not_found = []
|
| 1716 |
doc2 =fitz.open('pdf',merged_pdf)
|
| 1717 |
len_doc2 = len(doc2)
|
|
@@ -1743,5 +1642,3 @@ def mainRun(schedule, plan, searcharray):
|
|
| 1743 |
x,y,z=int(annot_color.get(v)[0]*255),int(annot_color.get(v)[1]*255),int(annot_color.get(v)[2]*255)
|
| 1744 |
list1.loc[len(list1)] =[annot.info['content'],annot.info['id'],annot.info['subject'],[x,y,z]]
|
| 1745 |
return annotatedimg, doc2 , list1, repeated_labels , not_found
|
| 1746 |
-
|
| 1747 |
-
|
|
|
|
| 1513 |
|
| 1514 |
dfs = extract_tables(schedule)
|
| 1515 |
|
|
|
|
|
|
|
|
|
|
| 1516 |
|
| 1517 |
+
for p in plan:
|
| 1518 |
+
all_new_data = []
|
| 1519 |
+
all_widths = []
|
| 1520 |
+
pdf_outputs = []
|
| 1521 |
+
|
| 1522 |
for j in range(len(searcharray)):
|
|
|
|
| 1523 |
user_input = searcharray[j]
|
| 1524 |
+
|
| 1525 |
secondary_presence = False
|
|
|
|
| 1526 |
if user_input[4] or user_input[5]:
|
| 1527 |
secondary_presence = True
|
|
|
|
| 1528 |
main_info_, secondary_info_ = separate_main_secondary(user_input)
|
|
|
|
| 1529 |
main_info = [item for item in main_info_ if item]
|
| 1530 |
+
secondary_info = [item for item in secondary_info_ if item]
|
|
|
|
| 1531 |
print("feh secondary information")
|
| 1532 |
if user_input[4]:
|
| 1533 |
print("Fire rate mawgooda")
|
| 1534 |
if user_input[5]:
|
| 1535 |
print("Acoustic Rate mawgooda")
|
|
|
|
| 1536 |
else:
|
| 1537 |
print("mafeesh secondary information")
|
| 1538 |
|
|
|
|
| 1540 |
kelma = get_st_op_pattern(selected_columns_combined, user_input)
|
| 1541 |
col_dict = get_similar_colors_all(selected_columns_combined)
|
| 1542 |
flattened_list = get_flattened_tuples_list_all(col_dict)
|
| 1543 |
+
plan_texts = read_text(p)
|
| 1544 |
+
|
| 1545 |
if secondary_presence:
|
|
|
|
| 1546 |
plan_texts = read_text(p)
|
| 1547 |
locations, not_found = get_word_locations_plan_secondary(flattened_list,plan_texts, main_info, secondary_info)
|
| 1548 |
new_data3 = get_cleaned_data_secondary(locations,main_info,secondary_info)
|
|
|
|
| 1556 |
width_info_tobeprinted, secondary_tobeprinted = get_width_info_tobeprinted_secondary(new_data3, main_info, secondary_info)
|
| 1557 |
cleaned_width = get_cleaned_width(width_info_tobeprinted)
|
| 1558 |
widths = get_widths_bb_format(cleaned_width, kelma)
|
| 1559 |
+
#Handling schedules without dimensions (width and height)
|
| 1560 |
+
if selected_columns_combined.shape[1] == 2:
|
| 1561 |
+
widths = []
|
| 1562 |
+
|
| 1563 |
secondary_printed_clean = get_secondary_tobeprinted_clean(selected_columns_combined, secondary_tobeprinted, secondary_info)
|
| 1564 |
all_print = mix_width_secondary(widths, secondary_printed_clean)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1565 |
|
| 1566 |
#Single page annotation
|
| 1567 |
all_widths.append(all_print)
|
| 1568 |
|
| 1569 |
+
#flat_list_new_data = [item for sublist in all_new_data for item in sublist]
|
| 1570 |
+
#flat_list_widths = [item for sublist in all_widths for item in sublist]
|
| 1571 |
|
| 1572 |
if pdf_outputs:
|
| 1573 |
final_pdf_bytes = process_pdf_secondary(pdf_outputs[j-1], "final_output_multiple_input_new2.pdf", all_new_data[j], all_widths[j], main_info, secondary_info)
|
| 1574 |
pdf_outputs.append(final_pdf_bytes)
|
| 1575 |
else:
|
| 1576 |
+
final_pdf_bytes = process_pdf_secondary(p, "final_output_multiple_input_new2.pdf", all_new_data[j], all_widths[j], main_info, secondary_info)
|
| 1577 |
pdf_outputs.append(final_pdf_bytes)
|
| 1578 |
+
|
|
|
|
|
|
|
|
|
|
| 1579 |
else:
|
| 1580 |
+
locations, not_found = get_word_locations_plan(flattened_list,plan_texts)
|
| 1581 |
+
new_data = get_cleaned_data(locations)
|
| 1582 |
+
#Single page annotation
|
| 1583 |
+
all_new_data.append(new_data)
|
| 1584 |
+
repeated_labels = get_repeated_labels(locations)
|
| 1585 |
+
if kelma == None:
|
| 1586 |
+
widths = get_width_info_tobeprinted(new_data)
|
| 1587 |
+
else:
|
| 1588 |
+
width_info_tobeprinted = get_width_info_tobeprinted(new_data)
|
| 1589 |
+
cleaned_width = get_cleaned_width(width_info_tobeprinted)
|
| 1590 |
+
widths = get_widths_bb_format(cleaned_width, kelma)
|
| 1591 |
+
|
| 1592 |
+
#Handling schedules without dimensions (width and height)
|
| 1593 |
+
if selected_columns_combined.shape[1] == 2:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1594 |
widths = []
|
| 1595 |
+
|
| 1596 |
+
#Single page annotation
|
| 1597 |
+
all_widths.append(widths)
|
| 1598 |
|
| 1599 |
+
flat_list_new_data = [item for sublist in all_new_data for item in sublist]
|
| 1600 |
+
flat_list_widths = [item for sublist in all_widths for item in sublist]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1601 |
|
| 1602 |
+
if pdf_outputs:
|
| 1603 |
+
final_pdf_bytes = process_pdf(pdf_outputs[j-1], "final_output_width_trial.pdf", all_new_data[j], all_widths[j])
|
| 1604 |
+
pdf_outputs.append(final_pdf_bytes)
|
| 1605 |
+
else:
|
| 1606 |
+
final_pdf_bytes = process_pdf(p, "final_output_width_trial.pdf", all_new_data[j], all_widths[j])
|
| 1607 |
+
pdf_outputs.append(final_pdf_bytes)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1608 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1609 |
|
| 1610 |
+
pdfs.append(final_pdf_bytes)
|
| 1611 |
+
merged_pdf = merge_pdf_bytes_list(pdfs)
|
| 1612 |
+
print(f"number of pges of merged_pdf is {len(merged_pdf)} and its type is {type(merged_pdf)}")
|
| 1613 |
+
|
| 1614 |
not_found = []
|
| 1615 |
doc2 =fitz.open('pdf',merged_pdf)
|
| 1616 |
len_doc2 = len(doc2)
|
|
|
|
| 1642 |
x,y,z=int(annot_color.get(v)[0]*255),int(annot_color.get(v)[1]*255),int(annot_color.get(v)[2]*255)
|
| 1643 |
list1.loc[len(list1)] =[annot.info['content'],annot.info['id'],annot.info['subject'],[x,y,z]]
|
| 1644 |
return annotatedimg, doc2 , list1, repeated_labels , not_found
|
|
|
|
|
|