Spaces:
Sleeping
Sleeping
Update Doors_Schedule
Browse files- Doors_Schedule +23 -5
Doors_Schedule
CHANGED
|
@@ -216,7 +216,7 @@ def get_selected_columns(dfs):
|
|
| 216 |
selected_columns.append((selected_columns_new, dfs[i],clm_idx, clmn_name, starting_row_index))
|
| 217 |
return selected_columns
|
| 218 |
|
| 219 |
-
def get_st_op_pattern(clm_idx, clmn_name, starting_row_index):
|
| 220 |
target = 'structural opening'
|
| 221 |
clm_dict = dict(clm_idx) # Convert list of tuples to dictionary
|
| 222 |
structural_opening_value = clm_dict.get(target) # Returns None if not found
|
|
@@ -266,7 +266,7 @@ def find_text_in_plan(label, x):
|
|
| 266 |
words.append(tpl[4])
|
| 267 |
return substring_coordinates, words, point_list
|
| 268 |
|
| 269 |
-
def get_word_locations_plan(flattened_list):
|
| 270 |
locations = []
|
| 271 |
not_found = []
|
| 272 |
for lbl, w, clr in flattened_list:
|
|
@@ -320,7 +320,7 @@ def get_cleaned_width(width_info_tobeprinted):
|
|
| 320 |
cleaned_width.append(clean_dimensions(w))
|
| 321 |
return cleaned_width
|
| 322 |
|
| 323 |
-
def get_widths_bb_format(cleaned_width):
|
| 324 |
pattern = r"\bW(?:idth)?\s*[×x]\s*H(?:eight)?\b"
|
| 325 |
match = re.search(pattern, kelma)
|
| 326 |
widths = []
|
|
@@ -415,5 +415,23 @@ def process_pdf(input_pdf_path, output_pdf_path, locations, new_authors):
|
|
| 415 |
#Save the final modified PDF to disk
|
| 416 |
with open(output_pdf_path, "wb") as file:
|
| 417 |
file.write(final_pdf_bytes)
|
| 418 |
-
|
| 419 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
selected_columns.append((selected_columns_new, dfs[i],clm_idx, clmn_name, starting_row_index))
|
| 217 |
return selected_columns
|
| 218 |
|
| 219 |
+
def get_st_op_pattern(clm_idx, clmn_name, starting_row_index, df):
|
| 220 |
target = 'structural opening'
|
| 221 |
clm_dict = dict(clm_idx) # Convert list of tuples to dictionary
|
| 222 |
structural_opening_value = clm_dict.get(target) # Returns None if not found
|
|
|
|
| 266 |
words.append(tpl[4])
|
| 267 |
return substring_coordinates, words, point_list
|
| 268 |
|
| 269 |
+
def get_word_locations_plan(flattened_list, plan_texts):
|
| 270 |
locations = []
|
| 271 |
not_found = []
|
| 272 |
for lbl, w, clr in flattened_list:
|
|
|
|
| 320 |
cleaned_width.append(clean_dimensions(w))
|
| 321 |
return cleaned_width
|
| 322 |
|
| 323 |
+
def get_widths_bb_format(cleaned_width, kelma):
|
| 324 |
pattern = r"\bW(?:idth)?\s*[×x]\s*H(?:eight)?\b"
|
| 325 |
match = re.search(pattern, kelma)
|
| 326 |
widths = []
|
|
|
|
| 415 |
#Save the final modified PDF to disk
|
| 416 |
with open(output_pdf_path, "wb") as file:
|
| 417 |
file.write(final_pdf_bytes)
|
| 418 |
+
def mainRun(schedule, plan):
|
| 419 |
+
dfs = extract_tables(schedule)
|
| 420 |
+
selected_columns = get_selected_columns(dfs)
|
| 421 |
+
selected_columns_new = selected_columns[0][0]
|
| 422 |
+
df = selected_columns[0][1]
|
| 423 |
+
clm_idx = selected_columns[0][2]
|
| 424 |
+
clmn_name = selected_columns[0][3]
|
| 425 |
+
starting_row_index = selected_columns[0][4]
|
| 426 |
+
kelma = get_st_op_pattern(clm_idx, clmn_name, starting_row_index,df)
|
| 427 |
+
col_dict = get_similar_colors(selected_columns_new)
|
| 428 |
+
flattened_list = get_flattened_tuples_list(col_dict)
|
| 429 |
+
plan_texts = read_text(plan)
|
| 430 |
+
locations, not_found = get_word_locations_plan(flattened_list,plan_texts)
|
| 431 |
+
new_data = get_cleaned_data(locations)
|
| 432 |
+
repeated_labels = get_repeated_labels(locations)
|
| 433 |
+
width_info_tobeprinted = get_width_info_tobeprinted(new_data)
|
| 434 |
+
cleaned_width = get_cleaned_width(width_info_tobeprinted)
|
| 435 |
+
widths = get_widths_bb_format(cleaned_width, kelma)
|
| 436 |
+
process_pdf(plan, "final_output_width.pdf", new_data, widths)
|
| 437 |
+
|